diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 97437f1..2c36dad 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -43,23 +43,16 @@ repositories { dependencies { implementation("androidx.lifecycle:lifecycle-livedata:2.5.1") - implementation("androidx.constraintlayout:constraintlayout:2.1.4") - implementation("com.google.android.material:material:1.9.0") - implementation("androidx.media:media:1.7.0") - implementation("androidx.navigation:navigation-ui:2.5.3") implementation("androidx.lifecycle:lifecycle-viewmodel:2.5.1") + implementation("androidx.media:media:1.7.0") implementation("androidx.appcompat:appcompat:1.6.1") - implementation("androidx.navigation:navigation-fragment:2.5.3") implementation("com.google.code.gson:gson:2.10.1") - implementation("com.github.bumptech.glide:glide:4.15.1") - annotationProcessor("com.github.bumptech.glide:compiler:4.15.1") implementation("com.google.firebase:firebase-auth:22.1.1") implementation("com.google.firebase:firebase-database:20.3.1") implementation("com.google.firebase:firebase-storage:20.3.0") implementation("com.google.android.gms:play-services-tasks:18.0.2") - implementation("com.squareup.okhttp3:okhttp:4.11.0") + implementation("com.google.android.material:material:1.13.0-alpha10") implementation("com.android.support:support-media-compat:28.0.0") - } apply(plugin = "com.google.gms.google-services") \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a739707..5292ba1 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -47,81 +47,29 @@ - - - - - - - - - - - - - - + android:name=".LandingActivity" + android:exported="false"/> + android:name=".LoginActivity" + android:theme="@style/Theme.Material3.Light.NoActionBar" + android:exported="false"/> + android:name=".PermissionsActivity" + android:exported="false"/> + android:name=".RegisterActivity" + android:exported="false"/> - - - - - - - - - - - - - + + android:name=".UpdateAppActivity" + android:exported="false"/> > theme_map = new ArrayList<>(); - - private LinearLayout linear1; - private ScrollView vscroll1; - private ImageView imageview1; - private TextView textview1; - private LinearLayout linear2; - private LinearLayout linear3; - private LinearLayout linear11; - private LinearLayout linear24; - private LinearLayout linear5; - private LinearLayout linear6; - private LinearLayout linear7; - private LinearLayout linear46; - private LinearLayout linear9; - private LinearLayout linear26; - private ImageView imageview2; - private LinearLayout linear25; - private LinearLayout linear4; - private TextView textview24; - private TextView textview11; - private TextView textview2; - private ImageView imageview3; - private LinearLayout linear8; - private TextView textview3; - private TextView textview4; - private ImageView imageview4; - private LinearLayout linear10; - private TextView textview5; - private TextView textview6; - private ImageView imageview22; - private LinearLayout linear47; - private TextView textview45; - private TextView textview46; - private ImageView imageview5; - private TextView textview12; - private ImageView imageview12; - private LinearLayout linear27; - private TextView textview25; - private TextView textview26; - private TextView textview7; - private LinearLayout linear12; - private LinearLayout linear14; - private LinearLayout linear40; - private LinearLayout linear30; - private LinearLayout linear16; - private LinearLayout linear22; - private LinearLayout linear42; - private LinearLayout linear44; - private LinearLayout linear36; - private ImageView imageview6; - private LinearLayout linear13; - private TextView textview14; - private TextView textview13; - private ImageView imageview7; - private LinearLayout linear15; - private TextView textview15; - private TextView textview16; - private ImageView imageview19; - private LinearLayout linear41; - private TextView textview39; - private TextView textview40; - private ImageView imageview14; - private LinearLayout linear31; - private TextView textview29; - private TextView textview30; - private ImageView imageview8; - private LinearLayout linear17; - private TextView textview17; - private TextView textview18; - private ImageView imageview11; - private LinearLayout linear23; - private TextView textview23; - private TextView textview8; - private ImageView imageview20; - private LinearLayout linear43; - private TextView textview41; - private TextView textview42; - private ImageView imageview21; - private LinearLayout linear45; - private TextView textview43; - private TextView textview44; - private ImageView imageview17; - private LinearLayout linear37; - private TextView textview35; - private TextView textview36; - private TextView textview9; - private LinearLayout linear28; - private LinearLayout linear32; - private LinearLayout linear34; - private LinearLayout linear38; - private LinearLayout linear18; - private LinearLayout linear20; - private ImageView imageview13; - private LinearLayout linear29; - private TextView textview27; - private TextView textview28; - private ImageView imageview15; - private LinearLayout linear33; - private TextView textview31; - private TextView textview32; - private ImageView imageview16; - private LinearLayout linear35; - private TextView textview33; - private TextView textview34; - private ImageView imageview18; - private LinearLayout linear39; - private TextView textview37; - private TextView textview38; - private ImageView imageview9; - private LinearLayout linear19; - private TextView textview20; - private TextView textview19; - private ImageView imageview10; - private LinearLayout linear21; - private TextView textview21; - private TextView textview22; - - private SharedPreferences data; - private Intent intentlol = new Intent(); - private Intent dataintent = new Intent(); - private AlertDialog.Builder dialog; - private Intent intentextra = new Intent(); - private DatabaseReference profile = _firebase.getReference("profile/text"); - private ChildEventListener _profile_child_listener; - private DatabaseReference prof_img = _firebase.getReference("profile/image"); - private ChildEventListener _prof_img_child_listener; - private double _easterEgg; - private double _easterEgg2; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.about); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - vscroll1 = findViewById(R.id.vscroll1); - imageview1 = findViewById(R.id.imageview1); - textview1 = findViewById(R.id.textview1); - linear2 = findViewById(R.id.linear2); - linear3 = findViewById(R.id.linear3); - linear11 = findViewById(R.id.linear11); - linear24 = findViewById(R.id.linear24); - linear5 = findViewById(R.id.linear5); - linear6 = findViewById(R.id.linear6); - linear7 = findViewById(R.id.linear7); - linear46 = findViewById(R.id.linear46); - linear9 = findViewById(R.id.linear9); - linear26 = findViewById(R.id.linear26); - imageview2 = findViewById(R.id.imageview2); - linear25 = findViewById(R.id.linear25); - linear4 = findViewById(R.id.linear4); - textview24 = findViewById(R.id.textview24); - textview11 = findViewById(R.id.textview11); - textview2 = findViewById(R.id.textview2); - imageview3 = findViewById(R.id.imageview3); - linear8 = findViewById(R.id.linear8); - textview3 = findViewById(R.id.textview3); - textview4 = findViewById(R.id.textview4); - imageview4 = findViewById(R.id.imageview4); - linear10 = findViewById(R.id.linear10); - textview5 = findViewById(R.id.textview5); - textview6 = findViewById(R.id.textview6); - imageview22 = findViewById(R.id.imageview22); - linear47 = findViewById(R.id.linear47); - textview45 = findViewById(R.id.textview45); - textview46 = findViewById(R.id.textview46); - imageview5 = findViewById(R.id.imageview5); - textview12 = findViewById(R.id.textview12); - imageview12 = findViewById(R.id.imageview12); - linear27 = findViewById(R.id.linear27); - textview25 = findViewById(R.id.textview25); - textview26 = findViewById(R.id.textview26); - textview7 = findViewById(R.id.textview7); - linear12 = findViewById(R.id.linear12); - linear14 = findViewById(R.id.linear14); - linear40 = findViewById(R.id.linear40); - linear30 = findViewById(R.id.linear30); - linear16 = findViewById(R.id.linear16); - linear22 = findViewById(R.id.linear22); - linear42 = findViewById(R.id.linear42); - linear44 = findViewById(R.id.linear44); - linear36 = findViewById(R.id.linear36); - imageview6 = findViewById(R.id.imageview6); - linear13 = findViewById(R.id.linear13); - textview14 = findViewById(R.id.textview14); - textview13 = findViewById(R.id.textview13); - imageview7 = findViewById(R.id.imageview7); - linear15 = findViewById(R.id.linear15); - textview15 = findViewById(R.id.textview15); - textview16 = findViewById(R.id.textview16); - imageview19 = findViewById(R.id.imageview19); - linear41 = findViewById(R.id.linear41); - textview39 = findViewById(R.id.textview39); - textview40 = findViewById(R.id.textview40); - imageview14 = findViewById(R.id.imageview14); - linear31 = findViewById(R.id.linear31); - textview29 = findViewById(R.id.textview29); - textview30 = findViewById(R.id.textview30); - imageview8 = findViewById(R.id.imageview8); - linear17 = findViewById(R.id.linear17); - textview17 = findViewById(R.id.textview17); - textview18 = findViewById(R.id.textview18); - imageview11 = findViewById(R.id.imageview11); - linear23 = findViewById(R.id.linear23); - textview23 = findViewById(R.id.textview23); - textview8 = findViewById(R.id.textview8); - imageview20 = findViewById(R.id.imageview20); - linear43 = findViewById(R.id.linear43); - textview41 = findViewById(R.id.textview41); - textview42 = findViewById(R.id.textview42); - imageview21 = findViewById(R.id.imageview21); - linear45 = findViewById(R.id.linear45); - textview43 = findViewById(R.id.textview43); - textview44 = findViewById(R.id.textview44); - imageview17 = findViewById(R.id.imageview17); - linear37 = findViewById(R.id.linear37); - textview35 = findViewById(R.id.textview35); - textview36 = findViewById(R.id.textview36); - textview9 = findViewById(R.id.textview9); - linear28 = findViewById(R.id.linear28); - linear32 = findViewById(R.id.linear32); - linear34 = findViewById(R.id.linear34); - linear38 = findViewById(R.id.linear38); - linear18 = findViewById(R.id.linear18); - linear20 = findViewById(R.id.linear20); - imageview13 = findViewById(R.id.imageview13); - linear29 = findViewById(R.id.linear29); - textview27 = findViewById(R.id.textview27); - textview28 = findViewById(R.id.textview28); - imageview15 = findViewById(R.id.imageview15); - linear33 = findViewById(R.id.linear33); - textview31 = findViewById(R.id.textview31); - textview32 = findViewById(R.id.textview32); - imageview16 = findViewById(R.id.imageview16); - linear35 = findViewById(R.id.linear35); - textview33 = findViewById(R.id.textview33); - textview34 = findViewById(R.id.textview34); - imageview18 = findViewById(R.id.imageview18); - linear39 = findViewById(R.id.linear39); - textview37 = findViewById(R.id.textview37); - textview38 = findViewById(R.id.textview38); - imageview9 = findViewById(R.id.imageview9); - linear19 = findViewById(R.id.linear19); - textview20 = findViewById(R.id.textview20); - textview19 = findViewById(R.id.textview19); - imageview10 = findViewById(R.id.imageview10); - linear21 = findViewById(R.id.linear21); - textview21 = findViewById(R.id.textview21); - textview22 = findViewById(R.id.textview22); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - dialog = new AlertDialog.Builder(this); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - linear5.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - dataintent.setData(Uri.parse("https://zrytezene.xyz")); - dataintent.setAction(Intent.ACTION_VIEW); - startActivity(dataintent); - } - }); - - linear6.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (!(_easterEgg > 9)) { - _easterEgg++; - } - } - }); - - linear7.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (!(_easterEgg2 > 9)) { - _easterEgg2++; - } - } - }); - - linear46.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - } - }); - - linear9.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - dialog.setCancelable(false); - dialog.setTitle("ZryteZene"); - dialog.setMessage("MIT License\nLast updated: 2019-10-05\n\nCopyright © 2017 ZryteZene All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice, this\n list of conditions and the following disclaimer in the documentation and/or\n other materials provided with the distribution.\n* Neither the name of ZryteZene nor the names of its contributors may be used to\n endorse or promote products derived from this software without specific prior\n written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\nTERMS AND CONDITIONS\nLast updated: 2020-04-05\n\n1. Introduction\n\nWelcome to Zrytezene (“Company”, “we”, “our”, “us”)!\n\nThese Terms of Service (“Terms”, “Terms of Service”) govern your use of our website located at https://zrytezene.web.app (together or individually “Service”) operated by ZryteZene.\n\nOur Privacy Policy also governs your use of our Service and explains how we collect, safeguard and disclose information that results from your use of our web pages.\n\nYour agreement with us includes these Terms and our Privacy Policy (“Agreements”). You acknowledge that you have read and understood Agreements, and agree to be bound of them.\n\nIf you do not agree with (or cannot comply with) Agreements, then you may not use the Service, but please let us know by emailing at zrytezene@gmail.com so we can try to find a solution. These Terms apply to all visitors, users and others who wish to access or use Service.\n\n2. Communications\n\nBy using our Service, you agree to subscribe to newsletters, marketing or promotional materials and other information we may send. However, you may opt out of receiving any, or all, of these communications from us by following the unsubscribe link or by emailing at zrytezene@gmail.com.\n\n3. Contests, Sweepstakes and Promotions\n\nAny contests, sweepstakes or other promotions (collectively, “Promotions”) made available through Service may be governed by rules that are separate from these Terms of Service. If you participate in any Promotions, please review the applicable rules as well as our Privacy Policy. If the rules for a Promotion conflict with these Terms of Service, Promotion rules will apply.\n\n4. Content\n\nOur Service allows you to post, link, store, share and otherwise make available certain information, text, graphics, videos, or other material (“Content”). You are responsible for Content that you post on or through Service, including its legality, reliability, and appropriateness.\n\nBy posting Content on or through Service, You represent and warrant that: (i) Content is yours (you own it) and/or you have the right to use it and the right to grant us the rights and license as provided in these Terms, and (ii) that the posting of your Content on or through Service does not violate the privacy rights, publicity rights, copyrights, contract rights or any other rights of any person or entity. We reserve the right to terminate the account of anyone found to be infringing on a copyright.\n\nYou retain any and all of your rights to any Content you submit, post or display on or through Service and you are responsible for protecting those rights. We take no responsibility and assume no liability for Content you or any third party posts on or through Service. However, by posting Content using Service you grant us the right and license to use, modify, publicly perform, publicly display, reproduce, and distribute such Content on and through Service. You agree that this license includes the right for us to make your Content available to other users of Service, who may also use your Content subject to these Terms.\n\nZryteZene has the right but not the obligation to monitor and edit all Content provided by users.\n\nIn addition, Content found on or through this Service are the property of ZryteZene or used with permission. You may not distribute, modify, transmit, reuse, download, repost, copy, or use said Content, whether in whole or in part, for commercial purposes or for personal gain, without express advance written permission from us.\n\n5. Prohibited Uses\n\nYou may use Service only for lawful purposes and in accordance with Terms. You agree not to use Service:\n\n0.1. In any way that violates any applicable national or international law or regulation.\n\n0.2. For the purpose of exploiting, harming, or attempting to exploit or harm minors in any way by exposing them to inappropriate content or otherwise.\n\n0.3. To transmit, or procure the sending of, any advertising or promotional material, including any “junk mail”, “chain letter,” “spam,” or any other similar solicitation.\n\n0.4. To impersonate or attempt to impersonate Company, a Company employee, another user, or any other person or entity.\n\n0.5. In any way that infringes upon the rights of others, or in any way is illegal, threatening, fraudulent, or harmful, or in connection with any unlawful, illegal, fraudulent, or harmful purpose or activity.\n\n0.6. To engage in any other conduct that restricts or inhibits anyone’s use or enjoyment of Service, or which, as determined by us, may harm or offend Company or users of Service or expose them to liability.\n\nAdditionally, you agree not to:\n\n0.1. Use Service in any manner that could disable, overburden, damage, or impair Service or interfere with any other party’s use of Service, including their ability to engage in real time activities through Service.\n\n0.2. Use any robot, spider, or other automatic device, process, or means to access Service for any purpose, including monitoring or copying any of the material on Service.\n\n0.3. Use any manual process to monitor or copy any of the material on Service or for any other unauthorized purpose without our prior written consent.\n\n0.4. Use any device, software, or routine that interferes with the proper working of Service.\n\n0.5. Introduce any viruses, trojan horses, worms, logic bombs, or other material which is malicious or technologically harmful.\n\n0.6. Attempt to gain unauthorized access to, interfere with, damage, or disrupt any parts of Service, the server on which Service is stored, or any server, computer, or database connected to Service.\n\n0.7. Attack Service via a denial-of-service attack or a distributed denial-of-service attack.\n\n0.8. Take any action that may damage or falsify Company rating.\n\n0.9. Otherwise attempt to interfere with the proper working of Service.\n\n6. Analytics\n\nWe may use third-party Service Providers to monitor and analyze the use of our Service.\n\n7. No Use By Minors\n\nService is intended only for access and use by individuals at least eighteen (18) years old. By accessing or using Service, you warrant and represent that you are at least eighteen (18) years of age and with the full authority, right, and capacity to enter into this agreement and abide by all of the terms and conditions of Terms. If you are not at least eighteen (18) years old, you are prohibited from both the access and usage of Service.\n\n8. Accounts\n\nWhen you create an account with us, you guarantee that you are above the age of 18, and that the information you provide us is accurate, complete, and current at all times. Inaccurate, incomplete, or obsolete information may result in the immediate termination of your account on Service.\n\nYou are responsible for maintaining the confidentiality of your account and password, including but not limited to the restriction of access to your computer and/or account. You agree to accept responsibility for any and all activities or actions that occur under your account and/or password, whether your password is with our Service or a third-party service. You must notify us immediately upon becoming aware of any breach of security or unauthorized use of your account.\n\nYou may not use as a username the name of another person or entity or that is not lawfully available for use, a name or trademark that is subject to any rights of another person or entity other than you, without appropriate authorization. You may not use as a username any name that is offensive, vulgar or obscene.\n\nWe reserve the right to refuse service, terminate accounts, remove or edit content, or cancel orders in our sole discretion.\n\n9. Intellectual Property\n\nService and its original content (excluding Content provided by users), features and functionality are and will remain the exclusive property of ZryteZene and its licensors. Service is protected by copyright, trademark, and other laws of and foreign countries. Our trademarks may not be used in connection with any product or service without the prior written consent of ZryteZene.\n\n10. Copyright Policy\n\nWe respect the intellectual property rights of others. It is our policy to respond to any claim that Content posted on Service infringes on the copyright or other intellectual property rights (“Infringement”) of any person or entity.\n\nIf you are a copyright owner, or authorized on behalf of one, and you believe that the copyrighted work has been copied in a way that constitutes copyright infringement, please submit your claim via email to zrytezene@gmail.com, with the subject line: “Copyright Infringement” and include in your claim a detailed description of the alleged Infringement as detailed below, under “DMCA Notice and Procedure for Copyright Infringement Claims”\n\nYou may be held accountable for damages (including costs and attorneys’ fees) for misrepresentation or bad-faith claims on the infringement of any Content found on and/or through Service on your copyright.\n\n11. DMCA Notice and Procedure for Copyright Infringement Claims\n\nYou may submit a notification pursuant to the Digital Millennium Copyright Act (DMCA) by providing our Copyright Agent with the following information in writing (see 17 U.S.C 512(c)(3) for further detail):\n\n0.1. an electronic or physical signature of the person authorized to act on behalf of the owner of the copyright’s interest;\n\n0.2. a description of the copyrighted work that you claim has been infringed, including the URL (i.e., web page address) of the location where the copyrighted work exists or a copy of the copyrighted work;\n\n0.3. identification of the URL or other specific location on Service where the material that you claim is infringing is located;\n\n0.4. your address, telephone number, and email address;\n\n0.5. a statement by you that you have a good faith belief that the disputed use is not authorized by the copyright owner, its agent, or the law;\n\n0.6. a statement by you, made under penalty of perjury, that the above information in your notice is accurate and that you are the copyright owner or authorized to act on the copyright owner’s behalf.\n\nYou can contact our Copyright Agent via email at zrytezene@gmail.com.\n\n12. Error Reporting and Feedback\n\nYou may provide us either directly at zrytezene@gmail.com or via third party sites and tools with information and feedback concerning errors, suggestions for improvements, ideas, problems, complaints, and other matters related to our Service (“Feedback”). You acknowledge and agree that: (i) you shall not retain, acquire or assert any intellectual property right or other right, title or interest in or to the Feedback; (ii) Company may have development ideas similar to the Feedback; (iii) Feedback does not contain confidential information or proprietary information from you or any third party; and (iv) Company is not under any obligation of confidentiality with respect to the Feedback. In the event the transfer of the ownership to the Feedback is not possible due to applicable mandatory laws, you grant Company and its affiliates an exclusive, transferable, irrevocable, free-of-charge, sub-licensable, unlimited and perpetual right to use (including copy, modify, create derivative works, publish, distribute and commercialize) Feedback in any manner and for any purpose.\n\n13. Links To Other Web Sites\n\nOur Service may contain links to third party web sites or services that are not owned or controlled by ZryteZene.\n\nZryteZene has no control over, and assumes no responsibility for the content, privacy policies, or practices of any third party web sites or services. We do not warrant the offerings of any of these entities/individuals or their websites.\n\nFor example, the outlined Terms of Service have been created using PolicyMaker.io, a free web application for generating high-quality legal documents. PolicyMaker’s free Terms and Conditions generator is an easy-to-use free tool for creating an excellent Terms of Service template for a website, blog, online store or app.\n\nYOU ACKNOWLEDGE AND AGREE THAT COMPANY SHALL NOT BE RESPONSIBLE OR LIABLE, DIRECTLY OR INDIRECTLY, FOR ANY DAMAGE OR LOSS CAUSED OR ALLEGED TO BE CAUSED BY OR IN CONNECTION WITH USE OF OR RELIANCE ON ANY SUCH CONTENT, GOODS OR SERVICES AVAILABLE ON OR THROUGH ANY SUCH THIRD PARTY WEB SITES OR SERVICES.\n\nWE STRONGLY ADVISE YOU TO READ THE TERMS OF SERVICE AND PRIVACY POLICIES OF ANY THIRD PARTY WEB SITES OR SERVICES THAT YOU VISIT.\n\n14. Disclaimer Of Warranty\n\nTHESE SERVICES ARE PROVIDED BY COMPANY ON AN “AS IS” AND “AS AVAILABLE” BASIS. COMPANY MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF THEIR SERVICES, OR THE INFORMATION, CONTENT OR MATERIALS INCLUDED THEREIN. YOU EXPRESSLY AGREE THAT YOUR USE OF THESE SERVICES, THEIR CONTENT, AND ANY SERVICES OR ITEMS OBTAINED FROM US IS AT YOUR SOLE RISK.\n\nNEITHER COMPANY NOR ANY PERSON ASSOCIATED WITH COMPANY MAKES ANY WARRANTY OR REPRESENTATION WITH RESPECT TO THE COMPLETENESS, SECURITY, RELIABILITY, QUALITY, ACCURACY, OR AVAILABILITY OF THE SERVICES. WITHOUT LIMITING THE FOREGOING, NEITHER COMPANY NOR ANYONE ASSOCIATED WITH COMPANY REPRESENTS OR WARRANTS THAT THE SERVICES, THEIR CONTENT, OR ANY SERVICES OR ITEMS OBTAINED THROUGH THE SERVICES WILL BE ACCURATE, RELIABLE, ERROR-FREE, OR UNINTERRUPTED, THAT DEFECTS WILL BE CORRECTED, THAT THE SERVICES OR THE SERVER THAT MAKES IT AVAILABLE ARE FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS OR THAT THE SERVICES OR ANY SERVICES OR ITEMS OBTAINED THROUGH THE SERVICES WILL OTHERWISE MEET YOUR NEEDS OR EXPECTATIONS.\n\nCOMPANY HEREBY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, STATUTORY, OR OTHERWISE, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, AND FITNESS FOR PARTICULAR PURPOSE.\n\nTHE FOREGOING DOES NOT AFFECT ANY WARRANTIES WHICH CANNOT BE EXCLUDED OR LIMITED UNDER APPLICABLE LAW.\n\n15. Limitation Of Liability\n\nEXCEPT AS PROHIBITED BY LAW, YOU WILL HOLD US AND OUR OFFICERS, DIRECTORS, EMPLOYEES, AND AGENTS HARMLESS FOR ANY INDIRECT, PUNITIVE, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGE, HOWEVER IT ARISES (INCLUDING ATTORNEYS’ FEES AND ALL RELATED COSTS AND EXPENSES OF LITIGATION AND ARBITRATION, OR AT TRIAL OR ON APPEAL, IF ANY, WHETHER OR NOT LITIGATION OR ARBITRATION IS INSTITUTED), WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, OR ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT, INCLUDING WITHOUT LIMITATION ANY CLAIM FOR PERSONAL INJURY OR PROPERTY DAMAGE, ARISING FROM THIS AGREEMENT AND ANY VIOLATION BY YOU OF ANY FEDERAL, STATE, OR LOCAL LAWS, STATUTES, RULES, OR REGULATIONS, EVEN IF COMPANY HAS BEEN PREVIOUSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EXCEPT AS PROHIBITED BY LAW, IF THERE IS LIABILITY FOUND ON THE PART OF COMPANY, IT WILL BE LIMITED TO THE AMOUNT PAID FOR THE PRODUCTS AND/OR SERVICES, AND UNDER NO CIRCUMSTANCES WILL THERE BE CONSEQUENTIAL OR PUNITIVE DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF PUNITIVE, INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE PRIOR LIMITATION OR EXCLUSION MAY NOT APPLY TO YOU.\n\n16. Termination\n\nWe may terminate or suspend your account and bar access to Service immediately, without prior notice or liability, under our sole discretion, for any reason whatsoever and without limitation, including but not limited to a breach of Terms.\n\nIf you wish to terminate your account, you may simply discontinue using Service.\n\nAll provisions of Terms which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability.\n\n17. Governing Law\n\nThese Terms shall be governed and construed in accordance with the laws of Indonesia, which governing law applies to agreement without regard to its conflict of law provisions.\n\nOur failure to enforce any right or provision of these Terms will not be considered a waiver of those rights. If any provision of these Terms is held to be invalid or unenforceable by a court, the remaining provisions of these Terms will remain in effect. These Terms constitute the entire agreement between us regarding our Service and supersede and replace any prior agreements we might have had between us regarding Service.\n\n18. Changes To Service\n\nWe reserve the right to withdraw or amend our Service, and any service or material we provide via Service, in our sole discretion without notice. We will not be liable if for any reason all or any part of Service is unavailable at any time or for any period. From time to time, we may restrict access to some parts of Service, or the entire Service, to users, including registered users.\n\n19. Amendments To Terms\n\nWe may amend Terms at any time by posting the amended terms on this site. It is your responsibility to review these Terms periodically.\n\nYour continued use of the Platform following the posting of revised Terms means that you accept and agree to the changes. You are expected to check this page frequently so you are aware of any changes, as they are binding on you.\n\nBy continuing to access or use our Service after any revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, you are no longer authorized to use Service.\n\n20. Waiver And Severability\n\nNo waiver by Company of any term or condition set forth in Terms shall be deemed a further or continuing waiver of such term or condition or a waiver of any other term or condition, and any failure of Company to assert a right or provision under Terms shall not constitute a waiver of such right or provision.\n\nIf any provision of Terms is held by a court or other tribunal of competent jurisdiction to be invalid, illegal or unenforceable for any reason, such provision shall be eliminated or limited to the minimum extent such that the remaining provisions of Terms will continue in full force and effect.\n\n21. Acknowledgement\n\nBY USING SERVICE OR OTHER SERVICES PROVIDED BY US, YOU ACKNOWLEDGE THAT YOU HAVE READ THESE TERMS OF SERVICE AND AGREE TO BE BOUND BY THEM.\n\n22. Contact Us\n\nPlease send your feedback, comments, requests for technical support by email: zrytezene@gmail.com.\n\n\nPRIVACY POLICY\nEffective date: 2020-04-05\n\n1. Introduction\n\nWelcome to Zrytezene.\n\nZryteZene (“us”, “we”, or “our”) operates https://zrytezene.web.app (hereinafter referred to as “Service”).\n\nOur Privacy Policy governs your visit to https://zrytezene.web.app, and explains how we collect, safeguard and disclose information that results from your use of our Service.\n\nWe use your data to provide and improve Service. By using Service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, the terms used in this Privacy Policy have the same meanings as in our Terms and Conditions.\n\nOur Terms and Conditions (“Terms”) govern all use of our Service and together with the Privacy Policy constitutes your agreement with us (“agreement”).\n\n2. Definitions\n\nSERVICE means the https://zrytezene.web.app website operated by ZryteZene.\n\nPERSONAL DATA means data about a living individual who can be identified from those data (or from those and other information either in our possession or likely to come into our possession).\n\nUSAGE DATA is data collected automatically either generated by the use of Service or from Service infrastructure itself (for example, the duration of a page visit).\n\nCOOKIES are small files stored on your device (computer or mobile device).\n\nDATA CONTROLLER means a natural or legal person who (either alone or jointly or in common with other persons) determines the purposes for which and the manner in which any personal data are, or are to be, processed. For the purpose of this Privacy Policy, we are a Data Controller of your data.\n\nDATA PROCESSORS (OR SERVICE PROVIDERS) means any natural or legal person who processes the data on behalf of the Data Controller. We may use the services of various Service Providers in order to process your data more effectively.\n\nDATA SUBJECT is any living individual who is the subject of Personal Data.\n\nTHE USER is the individual using our Service. The User corresponds to the Data Subject, who is the subject of Personal Data.\n\n3. Information Collection and Use\n\nWe collect several different types of information for various purposes to provide and improve our Service to you.\n\n4. Types of Data Collected\n\nPersonal Data\n\nWhile using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you (“Personal Data”). Personally identifiable information may include, but is not limited to:\n\n0.1. Email address\n\n0.2. First name and last name\n\n0.3. Phone number\n\n0.4. Address, Country, State, Province, ZIP/Postal code, City\n\n0.5. Cookies and Usage Data\n\nWe may use your Personal Data to contact you with newsletters, marketing or promotional materials and other information that may be of interest to you. You may opt out of receiving any, or all, of these communications from us by following the unsubscribe link.\n\nUsage Data\n\nWe may also collect information that your browser sends whenever you visit our Service or when you access Service by or through any device (“Usage Data”).\n\nThis Usage Data may include information such as your computer’s Internet Protocol address (e.g. IP address), browser type, browser version, the pages of our Service that you visit, the time and date of your visit, the time spent on those pages, unique device identifiers and other diagnostic data.\n\nWhen you access Service with a device, this Usage Data may include information such as the type of device you use, your device unique ID, the IP address of your device, your device operating system, the type of Internet browser you use, unique device identifiers and other diagnostic data.\n\nTracking Cookies Data\n\nWe use cookies and similar tracking technologies to track the activity on our Service and we hold certain information.\n\nCookies are files with a small amount of data which may include an anonymous unique identifier. Cookies are sent to your browser from a website and stored on your device. Other tracking technologies are also used such as beacons, tags and scripts to collect and track information and to improve and analyze our Service.\n\nYou can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may not be able to use some portions of our Service.\n\nExamples of Cookies we use:\n\n0.1. Session Cookies: We use Session Cookies to operate our Service.\n\n0.2. Preference Cookies: We use Preference Cookies to remember your preferences and various settings.\n\n0.3. Security Cookies: We use Security Cookies for security purposes.\n\n0.4. Advertising Cookies: Advertising Cookies are used to serve you with advertisements that may be relevant to you and your interests.\n\nOther Data\n\nWhile using our Service, we may also collect the following information: sex, age, date of birth, place of birth, passport details, citizenship, registration at place of residence and actual address, telephone number (work, mobile), details of documents on education, qualification, professional training, employment agreements, non-disclosure agreements, information on bonuses and compensation, information on marital status, family members, social security (or other taxpayer identification) number, office location and other data.\n\n5. Use of Data\n\nZryteZene uses the collected data for various purposes:\n\n0.1. to provide and maintain our Service;\n\n0.2. to notify you about changes to our Service;\n\n0.3. to allow you to participate in interactive features of our Service when you choose to do so;\n\n0.4. to provide customer support;\n\n0.5. to gather analysis or valuable information so that we can improve our Service;\n\n0.6. to monitor the usage of our Service;\n\n0.7. to detect, prevent and address technical issues;\n\n0.8. to fulfil any other purpose for which you provide it;\n\n0.9. to carry out our obligations and enforce our rights arising from any contracts entered into between you and us, including for billing and collection;\n\n0.10. to provide you with notices about your account and/or subscription, including expiration and renewal notices, email-instructions, etc.;\n\n0.11. to provide you with news, special offers and general information about other goods, services and events which we offer that are similar to those that you have already purchased or enquired about unless you have opted not to receive such information;\n\n0.12. in any other way we may describe when you provide the information;\n\n0.13. for any other purpose with your consent.\n\n6. Retention of Data\n\nWe will retain your Personal Data only for as long as is necessary for the purposes set out in this Privacy Policy. We will retain and use your Personal Data to the extent necessary to comply with our legal obligations (for example, if we are required to retain your data to comply with applicable laws), resolve disputes, and enforce our legal agreements and policies.\n\nWe will also retain Usage Data for internal analysis purposes. Usage Data is generally retained for a shorter period, except when this data is used to strengthen the security or to improve the functionality of our Service, or we are legally obligated to retain this data for longer time periods.\n\n7. Transfer of Data\n\nYour information, including Personal Data, may be transferred to – and maintained on – computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ from those of your jurisdiction.\n\nIf you are located outside Indonesia and choose to provide information to us, please note that we transfer the data, including Personal Data, to Indonesia and process it there.\n\nYour consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer.\n\nZryteZene will take all the steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organisation or a country unless there are adequate controls in place including the security of your data and other personal information.\n\n8. Disclosure of Data\n\nWe may disclose personal information that we collect, or you provide:\n\n0.1. Disclosure for Law Enforcement.\n\nUnder certain circumstances, we may be required to disclose your Personal Data if required to do so by law or in response to valid requests by public authorities.\n\n0.2. Business Transaction.\n\nIf we or our subsidiaries are involved in a merger, acquisition or asset sale, your Personal Data may be transferred.\n\n0.3. Other cases. We may disclose your information also:\n\n0.3.1. to our subsidiaries and affiliates;\n\n0.3.2. to contractors, service providers, and other third parties we use to support our business;\n\n0.3.3. to fulfill the purpose for which you provide it;\n\n0.3.4. for the purpose of including your company’s logo on our website;\n\n0.3.5. for any other purpose disclosed by us when you provide the information;\n\n0.3.6. with your consent in any other cases;\n\n0.3.7. if we believe disclosure is necessary or appropriate to protect the rights, property, or safety of the Company, our customers, or others.\n\n9. Security of Data\n\nThe security of your data is important to us but remember that no method of transmission over the Internet or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.\n\n10. Service Providers\n\nWe may employ third party companies and individuals to facilitate our Service (“Service Providers”), provide Service on our behalf, perform Service-related services or assist us in analysing how our Service is used.\n\nThese third parties have access to your Personal Data only to perform these tasks on our behalf and are obligated not to disclose or use it for any other purpose.\n\n11. Analytics\n\nWe may use third-party Service Providers to monitor and analyze the use of our Service.\n\n12. CI/CD tools\n\nWe may use third-party Service Providers to automate the development process of our Service.\n\n13. Behavioral Remarketing\n\nWe may use remarketing services to advertise on third party websites to you after you visited our Service. We and our third-party vendors use cookies to inform, optimise and serve ads based on your past visits to our Service.\n\n14. Links to Other Sites\n\nOur Service may contain links to other sites that are not operated by us. If you click a third party link, you will be directed to that third party’s site. We strongly advise you to review the Privacy Policy of every site you visit.\n\nWe have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.\n\nFor example, the outlined Privacy Policy has been created using PolicyMaker.io, a free web application for generating high-quality legal documents. PolicyMaker’s online free privacy policy generator is an easy-to-use tool for creating privacy policy template for a website, blog, online store or app.\n\n15. Children’s Privacy\n\nOur Services are not intended for use by children under the age of 18 (“Child” or “Children”).\n\nWe do not knowingly collect personally identifiable information from Children under 18. If you become aware that a Child has provided us with Personal Data, please contact us. If we become aware that we have collected Personal Data from Children without verification of parental consent, we take steps to remove that information from our servers.\n\n16. Changes to This Privacy Policy\n\nWe may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.\n\nWe will let you know via email and/or a prominent notice on our Service, prior to the change becoming effective and update “effective date” at the top of this Privacy Policy.\n\nYou are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.\n\n17. Contact Us\n\nIf you have any questions about this Privacy Policy, please contact us by email: zrytezene@gmail.com.\n\n\nDISCLAIMER\nLast updated: 2020-04-05\n\nWEBSITE DISCLAIMER\n\nThe information provided by ZryteZene (“Company”, “we”, “our”, “us”) on https://zrytezene.web.app (the “Site”) is for general informational purposes only. All information on the Site is provided in good faith, however we make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability, or completeness of any information on the Site.\n\nUNDER NO CIRCUMSTANCE SHALL WE HAVE ANY LIABILITY TO YOU FOR ANY LOSS OR DAMAGE OF ANY KIND INCURRED AS A RESULT OF THE USE OF THE SITE OR RELIANCE ON ANY INFORMATION PROVIDED ON THE SITE. YOUR USE OF THE SITE AND YOUR RELIANCE ON ANY INFORMATION ON THE SITE IS SOLELY AT YOUR OWN RISK.\n\nEXTERNAL LINKS DISCLAIMER\n\nThe Site may contain (or you may be sent through the Site) links to other websites or content belonging to or originating from third parties or links to websites and features. Such external links are not investigated, monitored, or checked for accuracy, adequacy, validity, reliability, availability or completeness by us.\n\nFor example, the outlined Disclaimer has been created using PolicyMaker.io, a free web application for generating high-quality legal documents. PolicyMaker’s free website Disclaimer generator is an easy-to-use tool for creating an excellent Disclaimer template for a website, blog, eCommerce store or app.\n\nWE DO NOT WARRANT, ENDORSE, GUARANTEE, OR ASSUME RESPONSIBILITY FOR THE ACCURACY OR RELIABILITY OF ANY INFORMATION OFFERED BY THIRD-PARTY WEBSITES LINKED THROUGH THE SITE OR ANY WEBSITE OR FEATURE LINKED IN ANY BANNER OR OTHER ADVERTISING. WE WILL NOT BE A PARTY TO OR IN ANY WAY BE RESPONSIBLE FOR MONITORING ANY TRANSACTION BETWEEN YOU AND THIRD-PARTY PROVIDERS OF PRODUCTS OR SERVICES.\n\nAFFILIATES DISCLAIMER\n\nThe Site may contain links to affiliate websites, and we may receive an affiliate commission for any purchases or actions made by you on the affiliate websites using such links.\n\nERRORS AND OMISSIONS DISCLAIMER\n\nWhile we have made every attempt to ensure that the information contained in this site has been obtained from reliable sources, ZryteZene is not responsible for any errors or omissions or for the results obtained from the use of this information. All information in this site is provided “as is”, with no guarantee of completeness, accuracy, timeliness or of the results obtained from the use of this information, and without warranty of any kind, express or implied, including, but not limited to warranties of performance, merchantability, and fitness for a particular purpose.\n\nIn no event will ZryteZene, its related partnerships or corporations, or the partners, agents or employees thereof be liable to you or anyone else for any decision made or action taken in reliance on the information in this Site or for any consequential, special or similar damages, even if advised of the possibility of such damages.\n\nGUEST CONTRIBUTORS DISCLAIMER\n\nThis Site may include content from guest contributors and any views or opinions expressed in such posts are personal and do not represent those of ZryteZene or any of its staff or affiliates unless explicitly stated.\n\nLOGOS AND TRADEMARKS DISCLAIMER\n\nAll logos and trademarks of third parties referenced on https://zrytezene.web.app are the trademarks and logos of their respective owners. Any inclusion of such trademarks or logos does not imply or constitute any approval, endorsement or sponsorship of ZryteZene by such owners.\n\nCONTACT US\n\nShould you have any feedback, comments, requests for technical support or other inquiries, please contact us by email: zrytezene@gmail.com.\n"); - dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - dialog.create().show(); - } - }); - - linear26.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - dataintent.setData(Uri.parse("https://discord.gg/ERpx6dv")); - dataintent.setAction(Intent.ACTION_VIEW); - startActivity(dataintent); - } - }); - - linear12.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "kGGvvEghj5XfVBuX1obf2hTrjoc2"); - startActivity(intentextra); - } - }); - - linear14.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "XwzlFNWx8keGp1QaCHthA2QVbED2"); - startActivity(intentextra); - } - }); - - linear40.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "UpQOFTwn76RAsKcntwPvi6P90KA2"); - startActivity(intentextra); - } - }); - - linear30.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "tO70jxIr23V05U396Pck9SUUAKy2"); - startActivity(intentextra); - } - }); - - linear16.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "1Vy4K7yIVRbhbdnUxcjmRLQ3v2t2"); - startActivity(intentextra); - } - }); - - linear22.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "5FItT6oZk9PX67Z0yRspUVpghIK2"); - startActivity(intentextra); - } - }); - - linear42.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "Juc0IA2zV8PgIaHnDLFThqf39lr2"); - startActivity(intentextra); - } - }); - - linear44.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "v2uhfHvCAdSouilgGXHGBD5fdgA3"); - startActivity(intentextra); - } - }); - - linear36.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "pi9jaUVRZHWsaMkekOukiH4jTiR2"); - startActivity(intentextra); - } - }); - - linear28.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "nGBcLSDBxgdacBFCud9FNPKEMJD3"); - startActivity(intentextra); - } - }); - - linear32.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "8i03R0bTjoRSEXYNmC60Spt5nse2"); - startActivity(intentextra); - } - }); - - linear34.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "l9PruxPML6REkTNX9kkptMwsz2k2"); - startActivity(intentextra); - } - }); - - linear38.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "KGiEfKIV9SZb4dWn9kz5b2mHqiy1"); - startActivity(intentextra); - } - }); - - linear18.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "C0DTLHB86ocKJsfYSs9HIVMne832"); - startActivity(intentextra); - } - }); - - linear20.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intentextra.setClass(getApplicationContext(), ProfileActivity.class); - intentextra.putExtra("uid", "LN8dNfhd1wXPcoVexg8vFeLKhks1"); - startActivity(intentextra); - } - }); - - _profile_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals("kGGvvEghj5XfVBuX1obf2hTrjoc2")) { - textview14.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("XwzlFNWx8keGp1QaCHthA2QVbED2")) { - textview15.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("1Vy4K7yIVRbhbdnUxcjmRLQ3v2t2")) { - textview17.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("C0DTLHB86ocKJsfYSs9HIVMne832")) { - textview20.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("LN8dNfhd1wXPcoVexg8vFeLKhks1")) { - textview21.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("5FItT6oZk9PX67Z0yRspUVpghIK2")) { - textview23.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("nGBcLSDBxgdacBFCud9FNPKEMJD3")) { - textview27.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("tO70jxIr23V05U396Pck9SUUAKy2")) { - textview29.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("8i03R0bTjoRSEXYNmC60Spt5nse2")) { - textview31.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("l9PruxPML6REkTNX9kkptMwsz2k2")) { - textview33.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("pi9jaUVRZHWsaMkekOukiH4jTiR2")) { - textview35.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("KGiEfKIV9SZb4dWn9kz5b2mHqiy1")) { - textview37.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("UpQOFTwn76RAsKcntwPvi6P90KA2")) { - textview39.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("Juc0IA2zV8PgIaHnDLFThqf39lr2")) { - textview41.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("v2uhfHvCAdSouilgGXHGBD5fdgA3")) { - textview43.setText(_childValue.get("username").toString()); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals("kGGvvEghj5XfVBuX1obf2hTrjoc2")) { - textview14.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("XwzlFNWx8keGp1QaCHthA2QVbED2")) { - textview15.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("1Vy4K7yIVRbhbdnUxcjmRLQ3v2t2")) { - textview17.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("C0DTLHB86ocKJsfYSs9HIVMne832")) { - textview20.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("LN8dNfhd1wXPcoVexg8vFeLKhks1")) { - textview21.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("5FItT6oZk9PX67Z0yRspUVpghIK2")) { - textview23.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("nGBcLSDBxgdacBFCud9FNPKEMJD3")) { - textview27.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("tO70jxIr23V05U396Pck9SUUAKy2")) { - textview29.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("8i03R0bTjoRSEXYNmC60Spt5nse2")) { - textview31.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("l9PruxPML6REkTNX9kkptMwsz2k2")) { - textview33.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("pi9jaUVRZHWsaMkekOukiH4jTiR2")) { - textview35.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("KGiEfKIV9SZb4dWn9kz5b2mHqiy1")) { - textview37.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("UpQOFTwn76RAsKcntwPvi6P90KA2")) { - textview39.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("Juc0IA2zV8PgIaHnDLFThqf39lr2")) { - textview41.setText(_childValue.get("username").toString()); - } - if (_childKey.equals("v2uhfHvCAdSouilgGXHGBD5fdgA3")) { - textview43.setText(_childValue.get("username").toString()); - } - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile.addChildEventListener(_profile_child_listener); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals("kGGvvEghj5XfVBuX1obf2hTrjoc2")) { - imageview6.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview6) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview6.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("XwzlFNWx8keGp1QaCHthA2QVbED2")) { - imageview7.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview7) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview7.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("1Vy4K7yIVRbhbdnUxcjmRLQ3v2t2")) { - imageview8.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview8) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview8.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("C0DTLHB86ocKJsfYSs9HIVMne832")) { - imageview9.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview9) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview9.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("LN8dNfhd1wXPcoVexg8vFeLKhks1")) { - imageview10.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview10) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview10.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("5FItT6oZk9PX67Z0yRspUVpghIK2")) { - imageview11.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview11) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview11.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("nGBcLSDBxgdacBFCud9FNPKEMJD3")) { - imageview13.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview13) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview13.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("tO70jxIr23V05U396Pck9SUUAKy2")) { - imageview14.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview14) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview14.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("8i03R0bTjoRSEXYNmC60Spt5nse2")) { - imageview15.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview15) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview15.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("l9PruxPML6REkTNX9kkptMwsz2k2")) { - imageview16.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview16) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview16.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("pi9jaUVRZHWsaMkekOukiH4jTiR2")) { - imageview17.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview17) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview17.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("KGiEfKIV9SZb4dWn9kz5b2mHqiy1")) { - imageview18.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview18) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview18.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("UpQOFTwn76RAsKcntwPvi6P90KA2")) { - imageview19.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview19) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview19.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("Juc0IA2zV8PgIaHnDLFThqf39lr2")) { - imageview20.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview20) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview20.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("v2uhfHvCAdSouilgGXHGBD5fdgA3")) { - imageview21.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview21) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview21.setImageDrawable(circularBitmapDrawable); - } - }); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals("kGGvvEghj5XfVBuX1obf2hTrjoc2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview6) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview6.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("XwzlFNWx8keGp1QaCHthA2QVbED2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview7) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview7.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("1Vy4K7yIVRbhbdnUxcjmRLQ3v2t2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview8) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview8.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("C0DTLHB86ocKJsfYSs9HIVMne832")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview9) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview9.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("LN8dNfhd1wXPcoVexg8vFeLKhks1")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview10) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview10.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("5FItT6oZk9PX67Z0yRspUVpghIK2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview11) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview11.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("nGBcLSDBxgdacBFCud9FNPKEMJD3")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview13) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview13.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("tO70jxIr23V05U396Pck9SUUAKy2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview14) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview14.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("8i03R0bTjoRSEXYNmC60Spt5nse2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview15) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview15.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("l9PruxPML6REkTNX9kkptMwsz2k2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview16) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview16.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("pi9jaUVRZHWsaMkekOukiH4jTiR2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview17) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview17.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("KGiEfKIV9SZb4dWn9kz5b2mHqiy1")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview18) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview18.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("UpQOFTwn76RAsKcntwPvi6P90KA2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview19) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview19.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("Juc0IA2zV8PgIaHnDLFThqf39lr2")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview20) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview20.setImageDrawable(circularBitmapDrawable); - } - }); - } - if (_childKey.equals("v2uhfHvCAdSouilgGXHGBD5fdgA3")) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview21) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview21.setImageDrawable(circularBitmapDrawable); - } - }); - } - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - linear34.setVisibility(View.GONE); - _setFont(); - _loadTheme(); - try { - android.content.pm.PackageInfo packageInfo = AboutActivity.this.getPackageManager().getPackageInfo(getPackageName(), 0); - - textview4.setText(packageInfo.versionName); - textview6.setText("2020.07.02_".concat(packageInfo.versionName.concat("-".concat(Integer.toString(packageInfo.versionCode))))); - } catch (Exception error) { - } - linear16.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _vlol) { - intentlol.setClass(getApplicationContext(), SwthomeActivity.class); - intentlol.putExtra("eg", "2"); - startActivity(intentlol); - return true; - } - }); - linear6.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _vlol) { - if (_easterEgg > 9) { - intentlol.setClass(getApplicationContext(), SwthomeActivity.class); - intentlol.putExtra("eg", "0"); - startActivity(intentlol); - } - return true; - } - }); - linear7.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _vlol) { - if (_easterEgg2 > 9) { - intentlol.setClass(getApplicationContext(), SwthomeActivity.class); - intentlol.putExtra("eg", "1"); - startActivity(intentlol); - } - return true; - } - }); - } - /* -Glide.with(getApplicationContext()).load(Uri.parse("lol")).into(imageview1); -*/ - - public void drawableclass() { - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview1); - _rippleEffect(linear5, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear6, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear7, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear9, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear26, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear12, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear14, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear16, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear18, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear20, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear22, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear28, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear30, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear32, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear34, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear36, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear38, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear40, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear42, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear44, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear46, theme_map.get(0).get("colorRipple").toString()); - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - vscroll1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), theme_map.get(0).get("colorBackgroundCard").toString(), "#FFFFFF", 0, linear3); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), theme_map.get(0).get("colorBackgroundCard").toString(), "#FFFFFF", 0, linear11); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), theme_map.get(0).get("colorBackgroundCard").toString(), "#FFFFFF", 0, linear24); - imageview3.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview4.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview5.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview6.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview7.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview8.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview9.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview10.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview11.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview13.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview14.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview15.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview16.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview17.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview18.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview19.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview20.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview21.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview22.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - textview11.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview3.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview5.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview12.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview25.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview7.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview14.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview15.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview17.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview20.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview21.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview23.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview9.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview27.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview29.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview31.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview33.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview35.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview37.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview24.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview4.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview6.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview26.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview13.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview16.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview18.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview19.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview22.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview8.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview28.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview30.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview32.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview34.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview36.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview38.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview39.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview40.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview41.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview42.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview43.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview44.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview45.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview46.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - _shadow(linear3, 8); - _shadow(linear11, 8); - _shadow(linear24, 8); - } - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - private void _rippleEffect(final View _view, final String _color) { - _view.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(_color))); - _view.setClickable(true); - } - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - private void _setFont() { - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview5.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview6.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview7.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview8.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview9.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview11.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview12.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview13.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview14.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview15.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview16.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview17.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview18.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview19.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview20.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview21.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview22.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview23.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview24.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview25.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview26.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview27.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview28.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview29.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview30.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview31.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview32.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview33.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview34.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview35.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview36.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview37.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview38.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview39.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview40.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview41.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview42.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview43.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview44.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview45.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview46.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/ChgpicActivity.java b/app/src/main/java/tw/music/streamer/ChgpicActivity.java deleted file mode 100644 index acaf4c1..0000000 --- a/app/src/main/java/tw/music/streamer/ChgpicActivity.java +++ /dev/null @@ -1,1780 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.ColorFilter; -import android.graphics.Matrix; -import android.graphics.PointF; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.util.AttributeSet; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.GestureDetector; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.OnClickListener; -import android.view.View.OnTouchListener; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.bumptech.glide.Glide; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -public class ChgpicActivity extends AppCompatActivity { - - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - - private ArrayList> theme_map = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private LinearLayout linear3; - private ImageView imageview2; - private TextView textview1; - private ImageView imageview3; - private TextView textview2; - - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private DatabaseReference prof_img = _firebase.getReference("profile/image"); - private ChildEventListener _prof_img_child_listener; - private SharedPreferences data; - private Intent i = new Intent(); - private GestureImageView imageview1; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.chgpic); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - linear3 = findViewById(R.id.linear3); - imageview2 = findViewById(R.id.imageview2); - textview1 = findViewById(R.id.textview1); - imageview3 = findViewById(R.id.imageview3); - textview2 = findViewById(R.id.textview2); - Auth = FirebaseAuth.getInstance(); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - - imageview2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - imageview3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - i.setClass(getApplicationContext(), FilepickerActivity.class); - i.putExtra("fileType", "image/*"); - startActivity(i); - } - }); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - Glide.with(getApplicationContext()).load(_childValue.get("url").toString()).into(imageview1); - linear2.setVisibility(View.VISIBLE); - linear3.setVisibility(View.GONE); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - Glide.with(getApplicationContext()).load(_childValue.get("url").toString()).into(imageview1); - } - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT); - imageview1 = new GestureImageView(this); - imageview1.setLayoutParams(params); - imageview1.setScaleType(ImageView.ScaleType.FIT_CENTER); - linear2.addView(imageview1); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor("#000000")); - } - _loadTheme(); - _customNav("#000000"); - if (!getIntent().getStringExtra("uid").equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - imageview3.setVisibility(View.GONE); - } - linear2.setVisibility(View.GONE); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - if (!data.getString("tmpPath", "").equals("")) { - i.setClass(getApplicationContext(), CropActivity.class); - i.putExtra("path", data.getString("tmpPath", "")); - startActivity(i); - data.edit().remove("tmpPath").commit(); - finish(); - } - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - /* -Glide.with(getApplicationContext()).load(Uri.parse("lol")).into(imageview2); -*/ - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview2); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview3); - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public interface Animation { - boolean update(GestureImageView view, long time); - } - - public interface FlingAnimationListener { - void onMove(float x, float y); - - void onComplete(); - } - - public interface GestureImageViewListener { - void onTouch(float x, float y); - - void onScale(float scale); - - void onPosition(float x, float y); - } - - - public interface MoveAnimationListener { - void onMove(float x, float y); - } - - - public interface ZoomAnimationListener { - void onZoom(float scale, float x, float y); - - void onComplete(); - } - - public static class Animator extends Thread { - private GestureImageView view; - private Animation animation; - private boolean running = false; - private boolean active = false; - private long lastTime = -1L; - - public Animator(GestureImageView view, String threadName) { - super(threadName); - this.view = view; - } - - @Override - public void run() { - running = true; - while (running) { - while (active && animation != null) { - long time = System.currentTimeMillis(); - active = animation.update(view, time - lastTime); - view.redraw(); - lastTime = time; - while (active) { - try { - if (view.waitForDraw(32)) { - break; - } - } catch (InterruptedException ignore) { - active = false; - } - } - } - synchronized (this) { - if (running) { - try { - wait(); - } catch (InterruptedException ignore) { - } - } - } - } - } - - public synchronized void finish() { - running = false; - active = false; - notifyAll(); - } - - public void play(Animation transformer) { - if (active) { - cancel(); - } - this.animation = transformer; - activate(); - } - - public synchronized void activate() { - lastTime = System.currentTimeMillis(); - active = true; - notifyAll(); - } - - public void cancel() { - active = false; - } - } - - public static class FlingAnimation implements Animation { - private float velocityX; - private float velocityY; - private float factor = 0.95f; - private float threshold = 10; - private FlingAnimationListener listener; - - @Override - public boolean update(GestureImageView view, long time) { - float seconds = (float) time / 1000.0f; - float dx = velocityX * seconds; - float dy = velocityY * seconds; - velocityX *= factor; - velocityY *= factor; - boolean active = (Math.abs(velocityX) > threshold && Math.abs(velocityY) > threshold); - if (listener != null) { - listener.onMove(dx, dy); - if (!active) { - listener.onComplete(); - } - } - return active; - } - - public void setVelocityX(float velocityX) { - this.velocityX = velocityX; - } - - public void setVelocityY(float velocityY) { - this.velocityY = velocityY; - } - - public void setFactor(float factor) { - this.factor = factor; - } - - public void setListener(FlingAnimationListener listener) { - this.listener = listener; - } - } - - public static class FlingListener extends android.view.GestureDetector.SimpleOnGestureListener { - private float velocityX; - private float velocityY; - - @Override - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - this.velocityX = velocityX; - this.velocityY = velocityY; - return true; - } - - public float getVelocityX() { - return velocityX; - } - - public float getVelocityY() { - return velocityY; - } - } - - public static class GestureImageView extends ImageView { - public static final String GLOBAL_NS = "http://schemas.android.com/apk/res/android"; - public static final String LOCAL_NS = "http://schemas.polites.com/android"; - private final java.util.concurrent.Semaphore drawLock = new java.util.concurrent.Semaphore(0); - private Animator animator; - private android.graphics.drawable.Drawable drawable; - private float x = 0, y = 0; - private boolean layout = false; - private float scaleAdjust = 1.0f; - private float startingScale = -1.0f; - private float scale = 1.0f; - private float maxScale = 5.0f; - private float minScale = 0.75f; - private float fitScaleHorizontal = 1.0f; - private float fitScaleVertical = 1.0f; - private float rotation = 0.0f; - private float centerX; - private float centerY; - private Float startX, startY; - private int hWidth; - private int hHeight; - private int resId = -1; - private boolean recycle = false; - private boolean strict = false; - private int displayHeight; - private int displayWidth; - private int alpha = 255; - private ColorFilter colorFilter; - private int deviceOrientation = -1; - private int imageOrientation; - private GestureImageViewListener gestureImageViewListener; - private GestureImageViewTouchListener gestureImageViewTouchListener; - private OnTouchListener customOnTouchListener; - private OnClickListener onClickListener; - - public GestureImageView(Context context, AttributeSet attrs, int defStyle) { - this(context, attrs); - } - - public GestureImageView(Context context, AttributeSet attrs) { - super(context, attrs); - String scaleType = attrs.getAttributeValue(GLOBAL_NS, "scaleType"); - if (scaleType == null || scaleType.trim().length() == 0) { - setScaleType(ScaleType.CENTER_INSIDE); - } - String strStartX = attrs.getAttributeValue(LOCAL_NS, "start-x"); - String strStartY = attrs.getAttributeValue(LOCAL_NS, "start-y"); - if (strStartX != null && strStartX.trim().length() > 0) { - startX = Float.parseFloat(strStartX); - } - if (strStartY != null && strStartY.trim().length() > 0) { - startY = Float.parseFloat(strStartY); - } - setStartingScale(attrs.getAttributeFloatValue(LOCAL_NS, "start-scale", startingScale)); - setMinScale(attrs.getAttributeFloatValue(LOCAL_NS, "min-scale", minScale)); - setMaxScale(attrs.getAttributeFloatValue(LOCAL_NS, "max-scale", maxScale)); - setStrict(attrs.getAttributeBooleanValue(LOCAL_NS, "strict", strict)); - setRecycle(attrs.getAttributeBooleanValue(LOCAL_NS, "recycle", recycle)); - initImage(); - } - - public GestureImageView(Context context) { - super(context); - setScaleType(ScaleType.CENTER_INSIDE); - initImage(); - } - - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (drawable != null) { - int orientation = getResources().getConfiguration().orientation; - if (orientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) { - displayHeight = MeasureSpec.getSize(heightMeasureSpec); - if (getLayoutParams().width == android.view.ViewGroup.LayoutParams.WRAP_CONTENT) { - float ratio = (float) getImageWidth() / (float) getImageHeight(); - displayWidth = Math.round((float) displayHeight * ratio); - } else { - displayWidth = MeasureSpec.getSize(widthMeasureSpec); - } - } else { - displayWidth = MeasureSpec.getSize(widthMeasureSpec); - if (getLayoutParams().height == android.view.ViewGroup.LayoutParams.WRAP_CONTENT) { - float ratio = (float) getImageHeight() / (float) getImageWidth(); - displayHeight = Math.round((float) displayWidth * ratio); - } else { - displayHeight = MeasureSpec.getSize(heightMeasureSpec); - } - } - } else { - displayHeight = MeasureSpec.getSize(heightMeasureSpec); - displayWidth = MeasureSpec.getSize(widthMeasureSpec); - } - setMeasuredDimension(displayWidth, displayHeight); - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - if (changed || !layout) { - setupCanvas(displayWidth, displayHeight, getResources().getConfiguration().orientation); - } - } - - protected void setupCanvas(int measuredWidth, int measuredHeight, int orientation) { - if (deviceOrientation != orientation) { - layout = false; - deviceOrientation = orientation; - } - if (drawable != null && !layout) { - int imageWidth = getImageWidth(); - int imageHeight = getImageHeight(); - hWidth = Math.round(((float) imageWidth / 2.0f)); - hHeight = Math.round(((float) imageHeight / 2.0f)); - measuredWidth -= (getPaddingLeft() + getPaddingRight()); - measuredHeight -= (getPaddingTop() + getPaddingBottom()); - computeCropScale(imageWidth, imageHeight, measuredWidth, measuredHeight); - if (startingScale <= 0.0f) { - computeStartingScale(imageWidth, imageHeight, measuredWidth, measuredHeight); - } - scaleAdjust = startingScale; - this.centerX = (float) measuredWidth / 2.0f; - this.centerY = (float) measuredHeight / 2.0f; - if (startX == null) { - x = centerX; - } else { - x = startX; - } - if (startY == null) { - y = centerY; - } else { - y = startY; - } - gestureImageViewTouchListener = new GestureImageViewTouchListener(this, measuredWidth, measuredHeight); - if (isLandscape()) { - gestureImageViewTouchListener.setMinScale(minScale * fitScaleHorizontal); - } else { - gestureImageViewTouchListener.setMinScale(minScale * fitScaleVertical); - } - gestureImageViewTouchListener.setMaxScale(maxScale * startingScale); - gestureImageViewTouchListener.setFitScaleHorizontal(fitScaleHorizontal); - gestureImageViewTouchListener.setFitScaleVertical(fitScaleVertical); - gestureImageViewTouchListener.setCanvasWidth(measuredWidth); - gestureImageViewTouchListener.setCanvasHeight(measuredHeight); - gestureImageViewTouchListener.setOnClickListener(onClickListener); - drawable.setBounds(-hWidth, -hHeight, hWidth, hHeight); - super.setOnTouchListener(new OnTouchListener() { - @Override - public boolean onTouch(View v, MotionEvent event) { - if (customOnTouchListener != null) { - customOnTouchListener.onTouch(v, event); - } - return gestureImageViewTouchListener.onTouch(v, event); - } - }); - layout = true; - } - } - - protected void computeCropScale(int imageWidth, int imageHeight, int measuredWidth, int measuredHeight) { - fitScaleHorizontal = (float) measuredWidth / (float) imageWidth; - fitScaleVertical = (float) measuredHeight / (float) imageHeight; - } - - protected void computeStartingScale(int imageWidth, int imageHeight, int measuredWidth, int measuredHeight) { - switch (getScaleType()) { - case CENTER: - startingScale = 1.0f; - break; - case CENTER_CROP: - startingScale = Math.max((float) measuredHeight / (float) imageHeight, (float) measuredWidth / (float) imageWidth); - break; - case CENTER_INSIDE: - float wRatio = (float) imageWidth / (float) measuredWidth; - float hRatio = (float) imageHeight / (float) measuredHeight; - if (wRatio > hRatio) { - startingScale = fitScaleHorizontal; - } else { - startingScale = fitScaleVertical; - } - break; - } - } - - protected boolean isRecycled() { - if (drawable != null && drawable instanceof android.graphics.drawable.BitmapDrawable) { - Bitmap bitmap = ((android.graphics.drawable.BitmapDrawable) drawable).getBitmap(); - if (bitmap != null) { - return bitmap.isRecycled(); - } - } - return false; - } - - protected void recycle() { - if (recycle && drawable != null && drawable instanceof android.graphics.drawable.BitmapDrawable) { - Bitmap bitmap = ((android.graphics.drawable.BitmapDrawable) drawable).getBitmap(); - if (bitmap != null) { - bitmap.recycle(); - } - } - } - - @Override - protected void onDraw(Canvas canvas) { - if (layout) { - if (drawable != null && !isRecycled()) { - canvas.save(); - float adjustedScale = scale * scaleAdjust; - canvas.translate(x, y); - if (rotation != 0.0f) { - canvas.rotate(rotation); - } - if (adjustedScale != 1.0f) { - canvas.scale(adjustedScale, adjustedScale); - } - drawable.draw(canvas); - canvas.restore(); - } - if (drawLock.availablePermits() <= 0) { - drawLock.release(); - } - } - } - - public boolean waitForDraw(long timeout) throws InterruptedException { - return drawLock.tryAcquire(timeout, java.util.concurrent.TimeUnit.MILLISECONDS); - } - - @Override - protected void onAttachedToWindow() { - animator = new Animator(this, "GestureImageViewAnimator"); - animator.start(); - if (resId >= 0 && drawable == null) { - setImageResource(resId); - } - super.onAttachedToWindow(); - } - - public void animationStart(Animation animation) { - if (animator != null) { - animator.play(animation); - } - } - - public void animationStop() { - if (animator != null) { - animator.cancel(); - } - } - - @Override - protected void onDetachedFromWindow() { - if (animator != null) { - animator.finish(); - } - if (recycle && drawable != null && !isRecycled()) { - recycle(); - drawable = null; - } - super.onDetachedFromWindow(); - } - - protected void initImage() { - if (this.drawable != null) { - this.drawable.setAlpha(alpha); - this.drawable.setFilterBitmap(true); - if (colorFilter != null) { - this.drawable.setColorFilter(colorFilter); - } - } - if (!layout) { - requestLayout(); - redraw(); - } - } - - public void setImageBitmap(Bitmap image) { - this.drawable = new android.graphics.drawable.BitmapDrawable(getResources(), image); - initImage(); - } - - @Override - public void setImageDrawable(android.graphics.drawable.Drawable drawable) { - this.drawable = drawable; - initImage(); - } - - public void setImageResource(int id) { - if (this.drawable != null) { - this.recycle(); - } - if (id >= 0) { - this.resId = id; - setImageDrawable(getContext().getResources().getDrawable(id)); - } - } - - public int getScaledWidth() { - return Math.round(getImageWidth() * getScale()); - } - - public int getScaledHeight() { - return Math.round(getImageHeight() * getScale()); - } - - public int getImageWidth() { - if (drawable != null) { - return drawable.getIntrinsicWidth(); - } - return 0; - } - - public int getImageHeight() { - if (drawable != null) { - return drawable.getIntrinsicHeight(); - } - return 0; - } - - public void moveBy(float x, float y) { - this.x += x; - this.y += y; - } - - public void setPosition(float x, float y) { - this.x = x; - this.y = y; - } - - public void redraw() { - postInvalidate(); - } - - public void setMinScale(float min) { - this.minScale = min; - if (gestureImageViewTouchListener != null) { - gestureImageViewTouchListener.setMinScale(min * fitScaleHorizontal); - } - } - - public void setMaxScale(float max) { - this.maxScale = max; - if (gestureImageViewTouchListener != null) { - gestureImageViewTouchListener.setMaxScale(max * startingScale); - } - } - - public float getScale() { - return scaleAdjust; - } - - public void setScale(float scale) { - scaleAdjust = scale; - } - - public float getImageX() { - return x; - } - - public float getImageY() { - return y; - } - - public boolean isStrict() { - return strict; - } - - public void setStrict(boolean strict) { - this.strict = strict; - } - - public boolean isRecycle() { - return recycle; - } - - public void setRecycle(boolean recycle) { - this.recycle = recycle; - } - - public void reset() { - x = centerX; - y = centerY; - scaleAdjust = startingScale; - if (gestureImageViewTouchListener != null) { - gestureImageViewTouchListener.reset(); - } - redraw(); - } - - public void setRotation(float rotation) { - this.rotation = rotation; - } - - public GestureImageViewListener getGestureImageViewListener() { - return gestureImageViewListener; - } - - public void setGestureImageViewListener(GestureImageViewListener pinchImageViewListener) { - this.gestureImageViewListener = pinchImageViewListener; - } - - @Override - public android.graphics.drawable.Drawable getDrawable() { - return drawable; - } - - @Override - public void setAlpha(int alpha) { - this.alpha = alpha; - if (drawable != null) { - drawable.setAlpha(alpha); - } - } - - @Override - public void setColorFilter(ColorFilter cf) { - this.colorFilter = cf; - if (drawable != null) { - drawable.setColorFilter(cf); - } - } - - @Override - public void setImageURI(Uri mUri) { - if ("content".equals(mUri.getScheme())) { - try { - String[] orientationColumn = {android.provider.MediaStore.Images.Media.ORIENTATION}; - android.database.Cursor cur = getContext().getContentResolver().query(mUri, orientationColumn, null, null, null); - if (cur != null && cur.moveToFirst()) { - imageOrientation = cur.getInt(cur.getColumnIndex(orientationColumn[0])); - } - java.io.InputStream in = null; - try { - in = getContext().getContentResolver().openInputStream(mUri); - Bitmap bmp = BitmapFactory.decodeStream(in); - if (imageOrientation != 0) { - Matrix m = new Matrix(); - m.postRotate(imageOrientation); - Bitmap rotated = Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), m, true); - bmp.recycle(); - setImageDrawable(new android.graphics.drawable.BitmapDrawable(getResources(), rotated)); - } else { - setImageDrawable(new android.graphics.drawable.BitmapDrawable(getResources(), bmp)); - } - } finally { - if (in != null) { - in.close(); - } - if (cur != null) { - cur.close(); - } - } - } catch (Exception e) { - } - } else { - setImageDrawable(android.graphics.drawable.Drawable.createFromPath(mUri.toString())); - } - if (drawable == null) { - mUri = null; - } - } - - @Override - public Matrix getImageMatrix() { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - return super.getImageMatrix(); - } - - @Override - public void setImageMatrix(Matrix matrix) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - } - - @Override - public void setScaleType(ScaleType scaleType) { - if (scaleType == ScaleType.CENTER || scaleType == ScaleType.CENTER_CROP || scaleType == ScaleType.CENTER_INSIDE) { - super.setScaleType(scaleType); - } else if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - } - - @Override - public void invalidateDrawable(android.graphics.drawable.Drawable dr) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - super.invalidateDrawable(dr); - } - - @Override - public int[] onCreateDrawableState(int extraSpace) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - return super.onCreateDrawableState(extraSpace); - } - - @Override - public void setAdjustViewBounds(boolean adjustViewBounds) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - super.setAdjustViewBounds(adjustViewBounds); - } - - @Override - public void setImageLevel(int level) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - super.setImageLevel(level); - } - - @Override - public void setImageState(int[] state, boolean merge) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - } - - @Override - public void setSelected(boolean selected) { - if (strict) { - throw new UnsupportedOperationException("Not supported"); - } - super.setSelected(selected); - } - - @Override - public void setOnTouchListener(OnTouchListener l) { - this.customOnTouchListener = l; - } - - public float getCenterX() { - return centerX; - } - - public float getCenterY() { - return centerY; - } - - public boolean isLandscape() { - return getImageWidth() >= getImageHeight(); - } - - public boolean isPortrait() { - return getImageWidth() <= getImageHeight(); - } - - public void setStartingScale(float startingScale) { - this.startingScale = startingScale; - } - - public void setStartingPosition(float x, float y) { - this.startX = x; - this.startY = y; - } - - @Override - public void setOnClickListener(OnClickListener l) { - this.onClickListener = l; - if (gestureImageViewTouchListener != null) { - gestureImageViewTouchListener.setOnClickListener(l); - } - } - - public boolean isOrientationAligned() { - if (deviceOrientation == android.content.res.Configuration.ORIENTATION_LANDSCAPE) { - return isLandscape(); - } else if (deviceOrientation == android.content.res.Configuration.ORIENTATION_PORTRAIT) { - return isPortrait(); - } - return true; - } - - public int getDeviceOrientation() { - return deviceOrientation; - } - } - - public static class GestureImageViewTouchListener implements OnTouchListener { - private final PointF current = new PointF(); - private final PointF last = new PointF(); - private final PointF next = new PointF(); - private final PointF midpoint = new PointF(); - private final VectorF scaleVector = new VectorF(); - private final VectorF pinchVector = new VectorF(); - private GestureImageView image; - private OnClickListener onClickListener; - private boolean touched = false; - private boolean inZoom = false; - private float initialDistance; - private float lastScale = 1.0f; - private float currentScale = 1.0f; - private float boundaryLeft = 0; - private float boundaryTop = 0; - private float boundaryRight = 0; - private float boundaryBottom = 0; - private float maxScale = 5.0f; - private float minScale = 0.25f; - private float fitScaleHorizontal = 1.0f; - private float fitScaleVertical = 1.0f; - private int canvasWidth = 0; - private int canvasHeight = 0; - private float centerX = 0; - private float centerY = 0; - private float startingScale = 0; - private boolean canDragX = false; - private boolean canDragY = false; - private boolean multiTouch = false; - private int displayWidth; - private int displayHeight; - private int imageWidth; - private int imageHeight; - private FlingListener flingListener; - private FlingAnimation flingAnimation; - private ZoomAnimation zoomAnimation; - private MoveAnimation moveAnimation; - private GestureDetector tapDetector; - private GestureDetector flingDetector; - private GestureImageViewListener imageListener; - - public GestureImageViewTouchListener(final GestureImageView image, int displayWidth, int displayHeight) { - super(); - this.image = image; - this.displayWidth = displayWidth; - this.displayHeight = displayHeight; - this.centerX = (float) displayWidth / 2.0f; - this.centerY = (float) displayHeight / 2.0f; - this.imageWidth = image.getImageWidth(); - this.imageHeight = image.getImageHeight(); - startingScale = image.getScale(); - currentScale = startingScale; - lastScale = startingScale; - boundaryRight = displayWidth; - boundaryBottom = displayHeight; - boundaryLeft = 0; - boundaryTop = 0; - next.x = image.getImageX(); - next.y = image.getImageY(); - flingListener = new FlingListener(); - flingAnimation = new FlingAnimation(); - zoomAnimation = new ZoomAnimation(); - moveAnimation = new MoveAnimation(); - flingAnimation.setListener(new FlingAnimationListener() { - @Override - public void onMove(float x, float y) { - handleDrag(current.x + x, current.y + y); - } - - @Override - public void onComplete() { - } - }); - zoomAnimation.setZoom(2.0f); - zoomAnimation.setZoomAnimationListener(new ZoomAnimationListener() { - @Override - public void onZoom(float scale, float x, float y) { - if (scale <= maxScale && scale >= minScale) { - handleScale(scale, x, y); - } - } - - @Override - public void onComplete() { - inZoom = false; - handleUp(); - } - }); - moveAnimation.setMoveAnimationListener(new MoveAnimationListener() { - @Override - public void onMove(float x, float y) { - image.setPosition(x, y); - image.redraw(); - } - }); - tapDetector = new GestureDetector(image.getContext(), new android.view.GestureDetector.SimpleOnGestureListener() { - @Override - public boolean onDoubleTap(MotionEvent e) { - startZoom(e); - return true; - } - - @Override - public boolean onSingleTapConfirmed(MotionEvent e) { - if (!inZoom) { - if (onClickListener != null) { - onClickListener.onClick(image); - return true; - } - } - return false; - } - }); - flingDetector = new GestureDetector(image.getContext(), flingListener); - imageListener = image.getGestureImageViewListener(); - calculateBoundaries(); - } - - private void startFling() { - flingAnimation.setVelocityX(flingListener.getVelocityX()); - flingAnimation.setVelocityY(flingListener.getVelocityY()); - image.animationStart(flingAnimation); - } - - private void startZoom(MotionEvent e) { - inZoom = true; - zoomAnimation.reset(); - float zoomTo; - if (image.isLandscape()) { - if (image.getDeviceOrientation() == android.content.res.Configuration.ORIENTATION_PORTRAIT) { - int scaledHeight = image.getScaledHeight(); - if (scaledHeight < canvasHeight) { - zoomTo = fitScaleVertical / currentScale; - zoomAnimation.setTouchX(e.getX()); - zoomAnimation.setTouchY(image.getCenterY()); - } else { - zoomTo = fitScaleHorizontal / currentScale; - zoomAnimation.setTouchX(image.getCenterX()); - zoomAnimation.setTouchY(image.getCenterY()); - } - } else { - int scaledWidth = image.getScaledWidth(); - if (scaledWidth == canvasWidth) { - zoomTo = currentScale * 4.0f; - zoomAnimation.setTouchX(e.getX()); - zoomAnimation.setTouchY(e.getY()); - } else if (scaledWidth < canvasWidth) { - zoomTo = fitScaleHorizontal / currentScale; - zoomAnimation.setTouchX(image.getCenterX()); - zoomAnimation.setTouchY(e.getY()); - } else { - zoomTo = fitScaleHorizontal / currentScale; - zoomAnimation.setTouchX(image.getCenterX()); - zoomAnimation.setTouchY(image.getCenterY()); - } - } - } else { - if (image.getDeviceOrientation() == android.content.res.Configuration.ORIENTATION_PORTRAIT) { - int scaledHeight = image.getScaledHeight(); - if (scaledHeight == canvasHeight) { - zoomTo = currentScale * 4.0f; - zoomAnimation.setTouchX(e.getX()); - zoomAnimation.setTouchY(e.getY()); - } else if (scaledHeight < canvasHeight) { - zoomTo = fitScaleVertical / currentScale; - zoomAnimation.setTouchX(e.getX()); - zoomAnimation.setTouchY(image.getCenterY()); - } else { - zoomTo = fitScaleVertical / currentScale; - zoomAnimation.setTouchX(image.getCenterX()); - zoomAnimation.setTouchY(image.getCenterY()); - } - } else { - int scaledWidth = image.getScaledWidth(); - if (scaledWidth < canvasWidth) { - zoomTo = fitScaleHorizontal / currentScale; - zoomAnimation.setTouchX(image.getCenterX()); - zoomAnimation.setTouchY(e.getY()); - } else { - zoomTo = fitScaleVertical / currentScale; - zoomAnimation.setTouchX(image.getCenterX()); - zoomAnimation.setTouchY(image.getCenterY()); - } - } - } - zoomAnimation.setZoom(zoomTo); - image.animationStart(zoomAnimation); - } - - private void stopAnimations() { - image.animationStop(); - } - - @Override - public boolean onTouch(View v, MotionEvent event) { - if (!inZoom) { - if (!tapDetector.onTouchEvent(event)) { - if (event.getPointerCount() == 1 && flingDetector.onTouchEvent(event)) { - startFling(); - } - if (event.getAction() == MotionEvent.ACTION_UP) { - handleUp(); - } else if (event.getAction() == MotionEvent.ACTION_DOWN) { - stopAnimations(); - last.x = event.getX(); - last.y = event.getY(); - if (imageListener != null) { - imageListener.onTouch(last.x, last.y); - } - touched = true; - } else if (event.getAction() == MotionEvent.ACTION_MOVE) { - if (event.getPointerCount() > 1) { - multiTouch = true; - if (initialDistance > 0) { - pinchVector.set(event); - pinchVector.calculateLength(); - float distance = pinchVector.length; - if (initialDistance != distance) { - float newScale = (distance / initialDistance) * lastScale; - if (newScale <= maxScale) { - scaleVector.length *= newScale; - scaleVector.calculateEndPoint(); - scaleVector.length /= newScale; - float newX = scaleVector.end.x; - float newY = scaleVector.end.y; - handleScale(newScale, newX, newY); - } - } - } else { - initialDistance = MathUtils.distance(event); - MathUtils.midpoint(event, midpoint); - scaleVector.setStart(midpoint); - scaleVector.setEnd(next); - scaleVector.calculateLength(); - scaleVector.calculateAngle(); - scaleVector.length /= lastScale; - } - } else { - if (!touched) { - touched = true; - last.x = event.getX(); - last.y = event.getY(); - next.x = image.getImageX(); - next.y = image.getImageY(); - } else if (!multiTouch) { - if (handleDrag(event.getX(), event.getY())) { - image.redraw(); - } - } - } - } - } - } - return true; - } - - protected void handleUp() { - multiTouch = false; - initialDistance = 0; - lastScale = currentScale; - if (!canDragX) { - next.x = centerX; - } - if (!canDragY) { - next.y = centerY; - } - boundCoordinates(); - if (!canDragX && !canDragY) { - if (image.isLandscape()) { - currentScale = fitScaleHorizontal; - lastScale = fitScaleHorizontal; - } else { - currentScale = fitScaleVertical; - lastScale = fitScaleVertical; - } - } - image.setScale(currentScale); - image.setPosition(next.x, next.y); - if (imageListener != null) { - imageListener.onScale(currentScale); - imageListener.onPosition(next.x, next.y); - } - image.redraw(); - } - - protected void handleScale(float scale, float x, float y) { - currentScale = scale; - if (currentScale > maxScale) { - currentScale = maxScale; - } else if (currentScale < minScale) { - currentScale = minScale; - } else { - next.x = x; - next.y = y; - } - calculateBoundaries(); - image.setScale(currentScale); - image.setPosition(next.x, next.y); - if (imageListener != null) { - imageListener.onScale(currentScale); - imageListener.onPosition(next.x, next.y); - } - image.redraw(); - } - - protected boolean handleDrag(float x, float y) { - current.x = x; - current.y = y; - float diffX = (current.x - last.x); - float diffY = (current.y - last.y); - if (diffX != 0 || diffY != 0) { - if (canDragX) next.x += diffX; - if (canDragY) next.y += diffY; - boundCoordinates(); - last.x = current.x; - last.y = current.y; - if (canDragX || canDragY) { - image.setPosition(next.x, next.y); - if (imageListener != null) { - imageListener.onPosition(next.x, next.y); - } - return true; - } - } - return false; - } - - public void reset() { - currentScale = startingScale; - next.x = centerX; - next.y = centerY; - calculateBoundaries(); - image.setScale(currentScale); - image.setPosition(next.x, next.y); - image.redraw(); - } - - public float getMaxScale() { - return maxScale; - } - - public void setMaxScale(float maxScale) { - this.maxScale = maxScale; - } - - public float getMinScale() { - return minScale; - } - - public void setMinScale(float minScale) { - this.minScale = minScale; - } - - public void setOnClickListener(OnClickListener onClickListener) { - this.onClickListener = onClickListener; - } - - protected void setCanvasWidth(int canvasWidth) { - this.canvasWidth = canvasWidth; - } - - protected void setCanvasHeight(int canvasHeight) { - this.canvasHeight = canvasHeight; - } - - protected void setFitScaleHorizontal(float fitScale) { - this.fitScaleHorizontal = fitScale; - } - - protected void setFitScaleVertical(float fitScaleVertical) { - this.fitScaleVertical = fitScaleVertical; - } - - protected void boundCoordinates() { - if (next.x < boundaryLeft) { - next.x = boundaryLeft; - } else if (next.x > boundaryRight) { - next.x = boundaryRight; - } - if (next.y < boundaryTop) { - next.y = boundaryTop; - } else if (next.y > boundaryBottom) { - next.y = boundaryBottom; - } - } - - protected void calculateBoundaries() { - int effectiveWidth = Math.round((float) imageWidth * currentScale); - int effectiveHeight = Math.round((float) imageHeight * currentScale); - canDragX = effectiveWidth > displayWidth; - canDragY = effectiveHeight > displayHeight; - if (canDragX) { - float diff = (float) (effectiveWidth - displayWidth) / 2.0f; - boundaryLeft = centerX - diff; - boundaryRight = centerX + diff; - } - if (canDragY) { - float diff = (float) (effectiveHeight - displayHeight) / 2.0f; - boundaryTop = centerY - diff; - boundaryBottom = centerY + diff; - } - } - } - - public static class MathUtils { - - public static float distance(MotionEvent event) { - float x = event.getX(0) - event.getX(1); - float y = event.getY(0) - event.getY(1); - return (float) Math.sqrt(x * x + y * y); - } - - public static float distance(PointF p1, PointF p2) { - float x = p1.x - p2.x; - float y = p1.y - p2.y; - return (float) Math.sqrt(x * x + y * y); - } - - public static float distance(float x1, float y1, float x2, float y2) { - float x = x1 - x2; - float y = y1 - y2; - return (float) Math.sqrt(x * x + y * y); - } - - public static void midpoint(MotionEvent event, PointF point) { - float x1 = event.getX(0); - float y1 = event.getY(0); - float x2 = event.getX(1); - float y2 = event.getY(1); - midpoint(x1, y1, x2, y2, point); - } - - public static void midpoint(float x1, float y1, float x2, float y2, PointF point) { - point.x = (x1 + x2) / 2.0f; - point.y = (y1 + y2) / 2.0f; - } - - public static float angle(PointF p1, PointF p2) { - return angle(p1.x, p1.y, p2.x, p2.y); - } - - public static float angle(float x1, float y1, float x2, float y2) { - return (float) Math.atan2(y2 - y1, x2 - x1); - } - - public void rotate(PointF p1, PointF p2, float angle) { - float px = p1.x; - float py = p1.y; - float ox = p2.x; - float oy = p2.y; - p1.x = ((float) Math.cos(angle) * (px - ox) - (float) Math.sin(angle) * (py - oy) + ox); - p1.y = ((float) Math.sin(angle) * (px - ox) + (float) Math.cos(angle) * (py - oy) + oy); - } - } - - public static class MoveAnimation implements Animation { - private boolean firstFrame = true; - private float startX; - private float startY; - private float targetX; - private float targetY; - private long animationTimeMS = 100; - private long totalTime = 0; - private MoveAnimationListener moveAnimationListener; - - @Override - public boolean update(GestureImageView view, long time) { - totalTime += time; - if (firstFrame) { - firstFrame = false; - startX = view.getImageX(); - startY = view.getImageY(); - } - if (totalTime < animationTimeMS) { - float ratio = (float) totalTime / animationTimeMS; - float newX = ((targetX - startX) * ratio) + startX; - float newY = ((targetY - startY) * ratio) + startY; - if (moveAnimationListener != null) { - moveAnimationListener.onMove(newX, newY); - } - return true; - } else { - if (moveAnimationListener != null) { - moveAnimationListener.onMove(targetX, targetY); - } - } - return false; - } - - public void reset() { - firstFrame = true; - totalTime = 0; - } - - public float getTargetX() { - return targetX; - } - - public void setTargetX(float targetX) { - this.targetX = targetX; - } - - public float getTargetY() { - return targetY; - } - - public void setTargetY(float targetY) { - this.targetY = targetY; - } - - public long getAnimationTimeMS() { - return animationTimeMS; - } - - public void setAnimationTimeMS(long animationTimeMS) { - this.animationTimeMS = animationTimeMS; - } - - public void setMoveAnimationListener(MoveAnimationListener moveAnimationListener) { - this.moveAnimationListener = moveAnimationListener; - } - } - - public static class VectorF { - public final PointF start = new PointF(); - public final PointF end = new PointF(); - public float angle; - public float length; - - public void calculateEndPoint() { - end.x = (float) Math.cos(angle) * length + start.x; - end.y = (float) Math.sin(angle) * length + start.y; - } - - public void setStart(PointF p) { - this.start.x = p.x; - this.start.y = p.y; - } - - public void setEnd(PointF p) { - this.end.x = p.x; - this.end.y = p.y; - } - - public void set(MotionEvent event) { - this.start.x = event.getX(0); - this.start.y = event.getY(0); - this.end.x = event.getX(1); - this.end.y = event.getY(1); - } - - public float calculateLength() { - length = MathUtils.distance(start, end); - return length; - } - - public float calculateAngle() { - angle = MathUtils.angle(start, end); - return angle; - } - } - - public static class ZoomAnimation implements Animation { - private boolean firstFrame = true; - private float touchX; - private float touchY; - private float zoom; - private float startX; - private float startY; - private float startScale; - private float xDiff; - private float yDiff; - private float scaleDiff; - private long animationLengthMS = 200; - private long totalTime = 0; - private ZoomAnimationListener zoomAnimationListener; - - @Override - public boolean update(GestureImageView view, long time) { - if (firstFrame) { - firstFrame = false; - startX = view.getImageX(); - startY = view.getImageY(); - startScale = view.getScale(); - scaleDiff = (zoom * startScale) - startScale; - if (scaleDiff > 0) { - VectorF vector = new VectorF(); - vector.setStart(new PointF(touchX, touchY)); - vector.setEnd(new PointF(startX, startY)); - vector.calculateAngle(); - float length = vector.calculateLength(); - vector.length = length * zoom; - vector.calculateEndPoint(); - xDiff = vector.end.x - startX; - yDiff = vector.end.y - startY; - } else { - xDiff = view.getCenterX() - startX; - yDiff = view.getCenterY() - startY; - } - } - totalTime += time; - float ratio = (float) totalTime / (float) animationLengthMS; - if (ratio < 1) { - if (ratio > 0) { - float newScale = (ratio * scaleDiff) + startScale; - float newX = (ratio * xDiff) + startX; - float newY = (ratio * yDiff) + startY; - if (zoomAnimationListener != null) { - zoomAnimationListener.onZoom(newScale, newX, newY); - } - } - return true; - } else { - float newScale = scaleDiff + startScale; - float newX = xDiff + startX; - float newY = yDiff + startY; - if (zoomAnimationListener != null) { - zoomAnimationListener.onZoom(newScale, newX, newY); - zoomAnimationListener.onComplete(); - } - return false; - } - } - - public void reset() { - firstFrame = true; - totalTime = 0; - } - - public float getZoom() { - return zoom; - } - - public void setZoom(float zoom) { - this.zoom = zoom; - } - - public float getTouchX() { - return touchX; - } - - public void setTouchX(float touchX) { - this.touchX = touchX; - } - - public float getTouchY() { - return touchY; - } - - public void setTouchY(float touchY) { - this.touchY = touchY; - } - - public long getAnimationLengthMS() { - return animationLengthMS; - } - - public void setAnimationLengthMS(long animationLengthMS) { - this.animationLengthMS = animationLengthMS; - } - - public ZoomAnimationListener getZoomAnimationListener() { - return zoomAnimationListener; - } - - public void setZoomAnimationListener(ZoomAnimationListener zoomAnimationListener) { - this.zoomAnimationListener = zoomAnimationListener; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/ColpickActivity.java b/app/src/main/java/tw/music/streamer/ColpickActivity.java deleted file mode 100644 index 6489cfc..0000000 --- a/app/src/main/java/tw/music/streamer/ColpickActivity.java +++ /dev/null @@ -1,161 +0,0 @@ -package tw.music.streamer; - -import android.content.Intent; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.widget.EditText; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ScrollView; -import android.widget.SeekBar; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import java.util.ArrayList; -import java.util.Random; - -public class ColpickActivity extends AppCompatActivity { - - - private ScrollView vscroll1; - private LinearLayout linear_colpick; - private LinearLayout bg_result; - private LinearLayout linear3; - private LinearLayout linear9; - private LinearLayout linear6; - private LinearLayout linear7; - private LinearLayout linear8; - private LinearLayout linear10; - private TextView text_hastag; - private EditText edit_hex; - private TextView text_a; - private TextView textview2; - private SeekBar seek_a; - private TextView textn_a; - private TextView text_r; - private TextView red_swatch; - private SeekBar seek_r; - private TextView textn_r; - private TextView text_g; - private TextView green_swatch; - private SeekBar seek_g; - private TextView textn_g; - private TextView text_b; - private TextView blue_swatch; - private SeekBar seek_b; - private TextView textn_b; - private TextView text_plhwarna; - private TextView text_axhyre; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.colpick); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - vscroll1 = findViewById(R.id.vscroll1); - linear_colpick = findViewById(R.id.linear_colpick); - bg_result = findViewById(R.id.bg_result); - linear3 = findViewById(R.id.linear3); - linear9 = findViewById(R.id.linear9); - linear6 = findViewById(R.id.linear6); - linear7 = findViewById(R.id.linear7); - linear8 = findViewById(R.id.linear8); - linear10 = findViewById(R.id.linear10); - text_hastag = findViewById(R.id.text_hastag); - edit_hex = findViewById(R.id.edit_hex); - text_a = findViewById(R.id.text_a); - textview2 = findViewById(R.id.textview2); - seek_a = findViewById(R.id.seek_a); - textn_a = findViewById(R.id.textn_a); - text_r = findViewById(R.id.text_r); - red_swatch = findViewById(R.id.red_swatch); - seek_r = findViewById(R.id.seek_r); - textn_r = findViewById(R.id.textn_r); - text_g = findViewById(R.id.text_g); - green_swatch = findViewById(R.id.green_swatch); - seek_g = findViewById(R.id.seek_g); - textn_g = findViewById(R.id.textn_g); - text_b = findViewById(R.id.text_b); - blue_swatch = findViewById(R.id.blue_swatch); - seek_b = findViewById(R.id.seek_b); - textn_b = findViewById(R.id.textn_b); - text_plhwarna = findViewById(R.id.text_plhwarna); - text_axhyre = findViewById(R.id.text_axhyre); - } - - private void initializeLogic() { - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - -} diff --git a/app/src/main/java/tw/music/streamer/CropActivity.java b/app/src/main/java/tw/music/streamer/CropActivity.java deleted file mode 100644 index 5aa89b5..0000000 --- a/app/src/main/java/tw/music/streamer/CropActivity.java +++ /dev/null @@ -1,1526 +0,0 @@ -package tw.music.streamer; - -import android.Manifest; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageManager; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.PointF; -import android.graphics.RectF; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.util.AttributeSet; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; - -import com.google.android.gms.tasks.Continuation; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.storage.FileDownloadTask; -import com.google.firebase.storage.FirebaseStorage; -import com.google.firebase.storage.OnProgressListener; -import com.google.firebase.storage.StorageReference; -import com.google.firebase.storage.UploadTask; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -public class CropActivity extends AppCompatActivity { - - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - private FirebaseStorage _firebase_storage = FirebaseStorage.getInstance(); - - private boolean isUploading = false; - private String path_file = ""; - private String url = ""; - private HashMap map = new HashMap<>(); - private String file_path = ""; - private boolean isReviewing = false; - - private ArrayList> img = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private ImageView imageview1; - private Button button1; - private LinearLayout linear3; - private Button button2; - - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private DatabaseReference prof_img = _firebase.getReference("profile/image"); - private ChildEventListener _prof_img_child_listener; - private StorageReference fbst_usr_img = _firebase_storage.getReference("profile/image"); - private OnCompleteListener _fbst_usr_img_upload_success_listener; - private OnSuccessListener _fbst_usr_img_download_success_listener; - private OnSuccessListener _fbst_usr_img_delete_success_listener; - private OnProgressListener _fbst_usr_img_upload_progress_listener; - private OnProgressListener _fbst_usr_img_download_progress_listener; - private OnFailureListener _fbst_usr_img_failure_listener; - private CropImageView crp; - private ProgressDialog coreprog; - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.crop); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED - || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000); - } else { - initializeLogic(); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1000) { - initializeLogic(); - } - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - imageview1 = findViewById(R.id.imageview1); - button1 = findViewById(R.id.button1); - linear3 = findViewById(R.id.linear3); - button2 = findViewById(R.id.button2); - Auth = FirebaseAuth.getInstance(); - - button1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - onBackPressed(); - } - }); - - button2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isReviewing) { - try { - isUploading = true; - if (FileUtil.isExistFile(file_path)) { - if (FileUtil.isFile(file_path)) { - if (21 > (FileUtil.getFileLength(file_path) / 1048576)) { - if (url.length() > 0) { - _firebase_storage.getReferenceFromUrl(url).delete().addOnSuccessListener(_fbst_usr_img_delete_success_listener).addOnFailureListener(_fbst_usr_img_failure_listener); - } - fbst_usr_img.child(FirebaseAuth.getInstance().getCurrentUser().getUid().concat("/".concat("profile-img.png"))).putFile(Uri.fromFile(new File(file_path))).addOnFailureListener(_fbst_usr_img_failure_listener).addOnProgressListener(_fbst_usr_img_upload_progress_listener).continueWithTask(new Continuation>() { - @Override - public Task then(Task task) throws Exception { - return fbst_usr_img.child(FirebaseAuth.getInstance().getCurrentUser().getUid().concat("/".concat("profile-img.png"))).getDownloadUrl(); - } - }).addOnCompleteListener(_fbst_usr_img_upload_success_listener); - _CoreProgressLoading(true); - } else { - SketchwareUtil.showMessage(getApplicationContext(), "File must be lower than 20MB!"); - _CoreProgressLoading(false); - isUploading = false; - finish(); - } - } else { - _CoreProgressLoading(false); - isUploading = false; - SketchwareUtil.showMessage(getApplicationContext(), "The following path isn't a file! (WTF are you doing bruh)"); - finish(); - } - } else { - _CoreProgressLoading(false); - isUploading = false; - SketchwareUtil.showMessage(getApplicationContext(), "File isn't exist! (Deleted or moved)"); - finish(); - } - } catch (Exception _e) { - _CoreProgressLoading(false); - isUploading = false; - SketchwareUtil.showMessage(getApplicationContext(), _e.getMessage()); - finish(); - } - } else { - try { - Bitmap croppedImage = crp.getCroppedImage(); - imageview1.setImageBitmap(croppedImage); - java.io.File file = new java.io.File(file_path); - java.io.FileOutputStream fOut = new java.io.FileOutputStream(file); - croppedImage.compress(Bitmap.CompressFormat.PNG, 100, fOut); - crp.setVisibility(View.GONE); - imageview1.setVisibility(View.VISIBLE); - button1.setText("Back"); - button2.setText("Done"); - isReviewing = true; - } catch (Exception _e) { - _CoreProgressLoading(false); - SketchwareUtil.showMessage(getApplicationContext(), _e.getMessage()); - finish(); - } - } - } - }); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - url = _childValue.get("url").toString(); - } - button2.setEnabled(true); - button2.setAlpha((float) (1.0d)); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - - _fbst_usr_img_upload_progress_listener = new OnProgressListener() { - @Override - public void onProgress(UploadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _fbst_usr_img_download_progress_listener = new OnProgressListener() { - @Override - public void onProgress(FileDownloadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _fbst_usr_img_upload_success_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final String _downloadUrl = _param1.getResult().toString(); - map = new HashMap<>(); - map.put("url", _downloadUrl); - prof_img.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).updateChildren(map); - if (FileUtil.isExistFile(file_path)) { - FileUtil.deleteFile(file_path); - } - _CoreProgressLoading(false); - isUploading = false; - SketchwareUtil.showMessage(getApplicationContext(), "Success!"); - finish(); - } - }; - - _fbst_usr_img_download_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot _param1) { - final long _totalByteCount = _param1.getTotalByteCount(); - - } - }; - - _fbst_usr_img_delete_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(Object _param1) { - - } - }; - - _fbst_usr_img_failure_listener = new OnFailureListener() { - @Override - public void onFailure(Exception _param1) { - final String _message = _param1.getMessage(); - SketchwareUtil.showMessage(getApplicationContext(), _message); - finish(); - } - }; - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - file_path = FileUtil.getPackageDataDir(getApplicationContext()).concat("/tmp_user.png"); - imageview1.setVisibility(View.GONE); - crp = new CropImageView(this); - LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); - lp.setMargins(0, 16, 0, 0); - crp.setLayoutParams(lp); - crp.setScaleType(ImageView.ScaleType.CENTER_INSIDE); - crp.setAdjustViewBounds(true); - crp.setFixedAspectRatio(true); - linear1.removeView(imageview1); - linear1.addView(crp, 0); - linear1.addView(imageview1); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor("#000000")); - } - _customNav("#000000"); - path_file = getIntent().getStringExtra("path"); - try { - crp.setImageBitmap(BitmapFactory.decodeFile(path_file)); - } catch (Exception _e) { - showMessage(_e.getMessage()); - } - button1.setAllCaps(false); - button2.setAllCaps(false); - button2.setEnabled(false); - button2.setAlpha((float) (0.5d)); - button1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onBackPressed() { - if (!isUploading) { - if (isReviewing) { - isReviewing = false; - if (FileUtil.isExistFile(file_path)) { - FileUtil.deleteFile(file_path); - } - crp.setVisibility(View.VISIBLE); - imageview1.setVisibility(View.GONE); - button1.setText("Cancel"); - button2.setText("Next"); - } else { - finish(); - } - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private void _CoreProgressLoading(final boolean _ifShow) { - if (_ifShow) { - if (coreprog == null) { - coreprog = new ProgressDialog(this); - coreprog.setCancelable(false); - coreprog.setCanceledOnTouchOutside(false); - - coreprog.requestWindowFeature(Window.FEATURE_NO_TITLE); - coreprog.getWindow().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(Color.TRANSPARENT)); - - } - coreprog.setMessage(null); - coreprog.show(); - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _coreView = _inflater.inflate(R.layout.custom_dialog, null); - final ImageView imageview1 = _coreView.findViewById(R.id.imageview1); - com.bumptech.glide.Glide.with(getApplicationContext()).load(R.raw.partyblob).into(imageview1); - coreprog.setContentView(_coreView); - } else { - if (coreprog != null) { - coreprog.dismiss(); - } - } - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - - public enum Handle { - TOP_LEFT(new CornerHandleHelper(Edge.TOP, Edge.LEFT)), - TOP_RIGHT(new CornerHandleHelper(Edge.TOP, Edge.RIGHT)), - BOTTOM_LEFT(new CornerHandleHelper(Edge.BOTTOM, Edge.LEFT)), - BOTTOM_RIGHT(new CornerHandleHelper(Edge.BOTTOM, Edge.RIGHT)), - LEFT(new VerticalHandleHelper(Edge.LEFT)), - TOP(new HorizontalHandleHelper(Edge.TOP)), - RIGHT(new VerticalHandleHelper(Edge.RIGHT)), - BOTTOM(new HorizontalHandleHelper(Edge.BOTTOM)), - CENTER(new CenterHandleHelper()); - private HandleHelper mHelper; - - Handle(HandleHelper helper) { - mHelper = helper; - } - - public void updateCropWindow(float x, - float y, - RectF imageRect, - float snapRadius) { - mHelper.updateCropWindow(x, y, imageRect, snapRadius); - } - - public void updateCropWindow(float x, - float y, - float targetAspectRatio, - RectF imageRect, - float snapRadius) { - mHelper.updateCropWindow(x, y, targetAspectRatio, imageRect, snapRadius); - } - } - - - public enum Edge { - LEFT, - TOP, - RIGHT, - BOTTOM; - public static final int MIN_CROP_LENGTH_PX = 40; - private float mCoordinate; - - public static float getWidth() { - return Edge.RIGHT.getCoordinate() - Edge.LEFT.getCoordinate(); - } - - public static float getHeight() { - return Edge.BOTTOM.getCoordinate() - Edge.TOP.getCoordinate(); - } - - private static float adjustLeft(float x, RectF imageRect, float imageSnapRadius, float aspectRatio) { - final float resultX; - if (x - imageRect.left < imageSnapRadius) { - resultX = imageRect.left; - } else { - float resultXHoriz = Float.POSITIVE_INFINITY; - float resultXVert = Float.POSITIVE_INFINITY; - if (x >= Edge.RIGHT.getCoordinate() - MIN_CROP_LENGTH_PX) { - resultXHoriz = Edge.RIGHT.getCoordinate() - MIN_CROP_LENGTH_PX; - } - if (((Edge.RIGHT.getCoordinate() - x) / aspectRatio) <= MIN_CROP_LENGTH_PX) { - resultXVert = Edge.RIGHT.getCoordinate() - (MIN_CROP_LENGTH_PX * aspectRatio); - } - resultX = Math.min(x, Math.min(resultXHoriz, resultXVert)); - } - return resultX; - } - - private static float adjustRight(float x, RectF imageRect, float imageSnapRadius, float aspectRatio) { - final float resultX; - if (imageRect.right - x < imageSnapRadius) { - resultX = imageRect.right; - } else { - float resultXHoriz = Float.NEGATIVE_INFINITY; - float resultXVert = Float.NEGATIVE_INFINITY; - if (x <= Edge.LEFT.getCoordinate() + MIN_CROP_LENGTH_PX) { - resultXHoriz = Edge.LEFT.getCoordinate() + MIN_CROP_LENGTH_PX; - } - if (((x - Edge.LEFT.getCoordinate()) / aspectRatio) <= MIN_CROP_LENGTH_PX) { - resultXVert = Edge.LEFT.getCoordinate() + (MIN_CROP_LENGTH_PX * aspectRatio); - } - resultX = Math.max(x, Math.max(resultXHoriz, resultXVert)); - } - return resultX; - } - - private static float adjustTop(float y, RectF imageRect, float imageSnapRadius, float aspectRatio) { - final float resultY; - if (y - imageRect.top < imageSnapRadius) { - resultY = imageRect.top; - } else { - float resultYVert = Float.POSITIVE_INFINITY; - float resultYHoriz = Float.POSITIVE_INFINITY; - if (y >= Edge.BOTTOM.getCoordinate() - MIN_CROP_LENGTH_PX) - resultYHoriz = Edge.BOTTOM.getCoordinate() - MIN_CROP_LENGTH_PX; - if (((Edge.BOTTOM.getCoordinate() - y) * aspectRatio) <= MIN_CROP_LENGTH_PX) - resultYVert = Edge.BOTTOM.getCoordinate() - (MIN_CROP_LENGTH_PX / aspectRatio); - resultY = Math.min(y, Math.min(resultYHoriz, resultYVert)); - } - return resultY; - } - - private static float adjustBottom(float y, RectF imageRect, float imageSnapRadius, float aspectRatio) { - final float resultY; - if (imageRect.bottom - y < imageSnapRadius) { - resultY = imageRect.bottom; - } else { - float resultYVert = Float.NEGATIVE_INFINITY; - float resultYHoriz = Float.NEGATIVE_INFINITY; - if (y <= Edge.TOP.getCoordinate() + MIN_CROP_LENGTH_PX) { - resultYVert = Edge.TOP.getCoordinate() + MIN_CROP_LENGTH_PX; - } - if (((y - Edge.TOP.getCoordinate()) * aspectRatio) <= MIN_CROP_LENGTH_PX) { - resultYHoriz = Edge.TOP.getCoordinate() + (MIN_CROP_LENGTH_PX / aspectRatio); - } - resultY = Math.max(y, Math.max(resultYHoriz, resultYVert)); - } - return resultY; - } - - public void offset(float distance) { - mCoordinate += distance; - } - - public float getCoordinate() { - return mCoordinate; - } - - public void setCoordinate(float coordinate) { - mCoordinate = coordinate; - } - - public void adjustCoordinate(float x, float y, RectF imageRect, float imageSnapRadius, float aspectRatio) { - switch (this) { - case LEFT: - mCoordinate = adjustLeft(x, imageRect, imageSnapRadius, aspectRatio); - break; - case TOP: - mCoordinate = adjustTop(y, imageRect, imageSnapRadius, aspectRatio); - break; - case RIGHT: - mCoordinate = adjustRight(x, imageRect, imageSnapRadius, aspectRatio); - break; - case BOTTOM: - mCoordinate = adjustBottom(y, imageRect, imageSnapRadius, aspectRatio); - break; - } - } - - public void adjustCoordinate(float aspectRatio) { - final float left = Edge.LEFT.getCoordinate(); - final float top = Edge.TOP.getCoordinate(); - final float right = Edge.RIGHT.getCoordinate(); - final float bottom = Edge.BOTTOM.getCoordinate(); - switch (this) { - case LEFT: - mCoordinate = AspectRatioUtil.calculateLeft(top, right, bottom, aspectRatio); - break; - case TOP: - mCoordinate = AspectRatioUtil.calculateTop(left, right, bottom, aspectRatio); - break; - case RIGHT: - mCoordinate = AspectRatioUtil.calculateRight(left, top, bottom, aspectRatio); - break; - case BOTTOM: - mCoordinate = AspectRatioUtil.calculateBottom(left, top, right, aspectRatio); - break; - } - } - - public boolean isNewRectangleOutOfBounds(Edge edge, RectF imageRect, float aspectRatio) { - final float offset = edge.snapOffset(imageRect); - switch (this) { - case LEFT: - if (edge.equals(Edge.TOP)) { - final float top = imageRect.top; - final float bottom = Edge.BOTTOM.getCoordinate() - offset; - final float right = Edge.RIGHT.getCoordinate(); - final float left = AspectRatioUtil.calculateLeft(top, right, bottom, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } else if (edge.equals(Edge.BOTTOM)) { - final float bottom = imageRect.bottom; - final float top = Edge.TOP.getCoordinate() - offset; - final float right = Edge.RIGHT.getCoordinate(); - final float left = AspectRatioUtil.calculateLeft(top, right, bottom, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } - break; - case TOP: - if (edge.equals(Edge.LEFT)) { - final float left = imageRect.left; - final float right = Edge.RIGHT.getCoordinate() - offset; - final float bottom = Edge.BOTTOM.getCoordinate(); - final float top = AspectRatioUtil.calculateTop(left, right, bottom, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } else if (edge.equals(Edge.RIGHT)) { - final float right = imageRect.right; - final float left = Edge.LEFT.getCoordinate() - offset; - final float bottom = Edge.BOTTOM.getCoordinate(); - final float top = AspectRatioUtil.calculateTop(left, right, bottom, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } - break; - case RIGHT: - if (edge.equals(Edge.TOP)) { - final float top = imageRect.top; - final float bottom = Edge.BOTTOM.getCoordinate() - offset; - final float left = Edge.LEFT.getCoordinate(); - final float right = AspectRatioUtil.calculateRight(left, top, bottom, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } else if (edge.equals(Edge.BOTTOM)) { - final float bottom = imageRect.bottom; - final float top = Edge.TOP.getCoordinate() - offset; - final float left = Edge.LEFT.getCoordinate(); - final float right = AspectRatioUtil.calculateRight(left, top, bottom, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } - break; - case BOTTOM: - if (edge.equals(Edge.LEFT)) { - final float left = imageRect.left; - final float right = Edge.RIGHT.getCoordinate() - offset; - final float top = Edge.TOP.getCoordinate(); - final float bottom = AspectRatioUtil.calculateBottom(left, top, right, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } else if (edge.equals(Edge.RIGHT)) { - final float right = imageRect.right; - final float left = Edge.LEFT.getCoordinate() - offset; - final float top = Edge.TOP.getCoordinate(); - final float bottom = AspectRatioUtil.calculateBottom(left, top, right, aspectRatio); - return isOutOfBounds(top, left, bottom, right, imageRect); - } - break; - } - return true; - } - - private boolean isOutOfBounds(float top, float left, float bottom, float right, RectF imageRect) { - return (top < imageRect.top || left < imageRect.left || bottom > imageRect.bottom || right > imageRect.right); - } - - public float snapToRect(RectF imageRect) { - final float oldCoordinate = mCoordinate; - switch (this) { - case LEFT: - mCoordinate = imageRect.left; - break; - case TOP: - mCoordinate = imageRect.top; - break; - case RIGHT: - mCoordinate = imageRect.right; - break; - case BOTTOM: - mCoordinate = imageRect.bottom; - break; - } - return mCoordinate - oldCoordinate; - } - - public float snapOffset(RectF imageRect) { - final float oldCoordinate = mCoordinate; - final float newCoordinate; - switch (this) { - case LEFT: - newCoordinate = imageRect.left; - break; - case TOP: - newCoordinate = imageRect.top; - break; - case RIGHT: - newCoordinate = imageRect.right; - break; - default: // BOTTOM - newCoordinate = imageRect.bottom; - break; - } - return newCoordinate - oldCoordinate; - } - - public boolean isOutsideMargin(RectF rect, float margin) { - final boolean result; - switch (this) { - case LEFT: - result = mCoordinate - rect.left < margin; - break; - case TOP: - result = mCoordinate - rect.top < margin; - break; - case RIGHT: - result = rect.right - mCoordinate < margin; - break; - default: // BOTTOM - result = rect.bottom - mCoordinate < margin; - break; - } - return result; - } - } - - public static class CropImageView extends ImageView { - @SuppressWarnings("unused") - public static final int GUIDELINES_OFF = 0; - public static final int GUIDELINES_ON_TOUCH = 1; - public static final int GUIDELINES_ON = 2; - @SuppressWarnings("unused") - private static final String TAG = CropImageView.class.getName(); - private Paint mBorderPaint; - private Paint mGuidelinePaint; - private Paint mCornerPaint; - private Paint mSurroundingAreaOverlayPaint; - private float mHandleRadius; - private float mSnapRadius; - private float mCornerThickness; - private float mBorderThickness; - private float mCornerLength; - private RectF mBitmapRect = new RectF(); - private PointF mTouchOffset = new PointF(); - private Handle mPressedHandle; - private boolean mFixAspectRatio; - private int mAspectRatioX = 1; - private int mAspectRatioY = 1; - private int mGuidelinesMode = 1; - - public CropImageView(Context context) { - super(context); - init(context, null); - } - - public CropImageView(Context context, AttributeSet attrs) { - super(context, attrs); - init(context, attrs); - } - - public CropImageView(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(context, attrs); - } - - private void init(Context context, AttributeSet attrs) { - - //final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CropImageView, 0, 0); - mGuidelinesMode = 1; - mFixAspectRatio = false; - mAspectRatioX = 1; - mAspectRatioY = 1; - - final android.content.res.Resources resources = context.getResources(); - - mBorderPaint = PaintUtil.newBorderPaint(resources); - mGuidelinePaint = PaintUtil.newGuidelinePaint(resources); - mSurroundingAreaOverlayPaint = PaintUtil.newSurroundingAreaOverlayPaint(resources); - mCornerPaint = PaintUtil.newCornerPaint(resources); - - mHandleRadius = 24; - mSnapRadius = 3; - mBorderThickness = 3; - mCornerThickness = 5; - mCornerLength = 20; - } - - @Override - protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - super.onLayout(changed, left, top, right, bottom); - mBitmapRect = getBitmapRect(); - initCropWindow(mBitmapRect); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - drawDarkenedSurroundingArea(canvas); - drawGuidelines(canvas); - drawBorder(canvas); - drawCorners(canvas); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - if (!isEnabled()) { - return false; - } - switch (event.getAction()) { - case MotionEvent.ACTION_DOWN: - onActionDown(event.getX(), event.getY()); - return true; - case MotionEvent.ACTION_UP: - case MotionEvent.ACTION_CANCEL: - getParent().requestDisallowInterceptTouchEvent(false); - onActionUp(); - return true; - case MotionEvent.ACTION_MOVE: - onActionMove(event.getX(), event.getY()); - getParent().requestDisallowInterceptTouchEvent(true); - return true; - default: - return false; - } - } - - public void setGuidelines(int guidelinesMode) { - mGuidelinesMode = guidelinesMode; - invalidate(); - } - - public void setFixedAspectRatio(boolean fixAspectRatio) { - mFixAspectRatio = fixAspectRatio; - requestLayout(); - } - - public void setAspectRatio(int aspectRatioX, int aspectRatioY) { - if (aspectRatioX <= 0 || aspectRatioY <= 0) { - throw new IllegalArgumentException("Cannot set aspect ratio value to a number less than or equal to 0."); - } - mAspectRatioX = aspectRatioX; - mAspectRatioY = aspectRatioY; - if (mFixAspectRatio) { - requestLayout(); - } - } - - public Bitmap getCroppedImage() { - final android.graphics.drawable.Drawable drawable = getDrawable(); - if (drawable == null || !(drawable instanceof android.graphics.drawable.BitmapDrawable)) { - return null; - } - final float[] matrixValues = new float[9]; - getImageMatrix().getValues(matrixValues); - final float scaleX = matrixValues[Matrix.MSCALE_X]; - final float scaleY = matrixValues[Matrix.MSCALE_Y]; - final float transX = matrixValues[Matrix.MTRANS_X]; - final float transY = matrixValues[Matrix.MTRANS_Y]; - final float bitmapLeft = (transX < 0) ? Math.abs(transX) : 0; - final float bitmapTop = (transY < 0) ? Math.abs(transY) : 0; - final Bitmap originalBitmap = ((android.graphics.drawable.BitmapDrawable) drawable).getBitmap(); - final float cropX = (bitmapLeft + Edge.LEFT.getCoordinate()) / scaleX; - final float cropY = (bitmapTop + Edge.TOP.getCoordinate()) / scaleY; - final float cropWidth = Math.min(Edge.getWidth() / scaleX, originalBitmap.getWidth() - cropX); - final float cropHeight = Math.min(Edge.getHeight() / scaleY, originalBitmap.getHeight() - cropY); - return Bitmap.createBitmap(originalBitmap, - (int) cropX, - (int) cropY, - (int) cropWidth, - (int) cropHeight); - } - - private RectF getBitmapRect() { - final android.graphics.drawable.Drawable drawable = getDrawable(); - if (drawable == null) { - return new RectF(); - } - final float[] matrixValues = new float[9]; - getImageMatrix().getValues(matrixValues); - final float scaleX = matrixValues[Matrix.MSCALE_X]; - final float scaleY = matrixValues[Matrix.MSCALE_Y]; - final float transX = matrixValues[Matrix.MTRANS_X]; - final float transY = matrixValues[Matrix.MTRANS_Y]; - final int drawableIntrinsicWidth = drawable.getIntrinsicWidth(); - final int drawableIntrinsicHeight = drawable.getIntrinsicHeight(); - final int drawableDisplayWidth = Math.round(drawableIntrinsicWidth * scaleX); - final int drawableDisplayHeight = Math.round(drawableIntrinsicHeight * scaleY); - final float left = Math.max(transX, 0); - final float top = Math.max(transY, 0); - final float right = Math.min(left + drawableDisplayWidth, getWidth()); - final float bottom = Math.min(top + drawableDisplayHeight, getHeight()); - return new RectF(left, top, right, bottom); - } - - private void initCropWindow(RectF bitmapRect) { - if (mFixAspectRatio) { - initCropWindowWithFixedAspectRatio(bitmapRect); - } else { - final float horizontalPadding = 0.1f * bitmapRect.width(); - final float verticalPadding = 0.1f * bitmapRect.height(); - Edge.LEFT.setCoordinate(bitmapRect.left + horizontalPadding); - Edge.TOP.setCoordinate(bitmapRect.top + verticalPadding); - Edge.RIGHT.setCoordinate(bitmapRect.right - horizontalPadding); - Edge.BOTTOM.setCoordinate(bitmapRect.bottom - verticalPadding); - } - } - - private void initCropWindowWithFixedAspectRatio(RectF bitmapRect) { - if (AspectRatioUtil.calculateAspectRatio(bitmapRect) > getTargetAspectRatio()) { - final float cropWidth = AspectRatioUtil.calculateWidth(bitmapRect.height(), getTargetAspectRatio()); - Edge.LEFT.setCoordinate(bitmapRect.centerX() - cropWidth / 2f); - Edge.TOP.setCoordinate(bitmapRect.top); - Edge.RIGHT.setCoordinate(bitmapRect.centerX() + cropWidth / 2f); - Edge.BOTTOM.setCoordinate(bitmapRect.bottom); - } else { - final float cropHeight = AspectRatioUtil.calculateHeight(bitmapRect.width(), getTargetAspectRatio()); - Edge.LEFT.setCoordinate(bitmapRect.left); - Edge.TOP.setCoordinate(bitmapRect.centerY() - cropHeight / 2f); - Edge.RIGHT.setCoordinate(bitmapRect.right); - Edge.BOTTOM.setCoordinate(bitmapRect.centerY() + cropHeight / 2f); - } - } - - private void drawDarkenedSurroundingArea(Canvas canvas) { - final RectF bitmapRect = mBitmapRect; - final float left = Edge.LEFT.getCoordinate(); - final float top = Edge.TOP.getCoordinate(); - final float right = Edge.RIGHT.getCoordinate(); - final float bottom = Edge.BOTTOM.getCoordinate(); - canvas.drawRect(bitmapRect.left, bitmapRect.top, bitmapRect.right, top, mSurroundingAreaOverlayPaint); - canvas.drawRect(bitmapRect.left, bottom, bitmapRect.right, bitmapRect.bottom, mSurroundingAreaOverlayPaint); - canvas.drawRect(bitmapRect.left, top, left, bottom, mSurroundingAreaOverlayPaint); - canvas.drawRect(right, top, bitmapRect.right, bottom, mSurroundingAreaOverlayPaint); - } - - private void drawGuidelines(Canvas canvas) { - if (!shouldGuidelinesBeShown()) { - return; - } - final float left = Edge.LEFT.getCoordinate(); - final float top = Edge.TOP.getCoordinate(); - final float right = Edge.RIGHT.getCoordinate(); - final float bottom = Edge.BOTTOM.getCoordinate(); - final float oneThirdCropWidth = Edge.getWidth() / 3; - final float x1 = left + oneThirdCropWidth; - canvas.drawLine(x1, top, x1, bottom, mGuidelinePaint); - final float x2 = right - oneThirdCropWidth; - canvas.drawLine(x2, top, x2, bottom, mGuidelinePaint); - final float oneThirdCropHeight = Edge.getHeight() / 3; - final float y1 = top + oneThirdCropHeight; - canvas.drawLine(left, y1, right, y1, mGuidelinePaint); - final float y2 = bottom - oneThirdCropHeight; - canvas.drawLine(left, y2, right, y2, mGuidelinePaint); - } - - private void drawBorder(Canvas canvas) { - canvas.drawRect(Edge.LEFT.getCoordinate(), - Edge.TOP.getCoordinate(), - Edge.RIGHT.getCoordinate(), - Edge.BOTTOM.getCoordinate(), - mBorderPaint); - } - - private void drawCorners(Canvas canvas) { - final float left = Edge.LEFT.getCoordinate(); - final float top = Edge.TOP.getCoordinate(); - final float right = Edge.RIGHT.getCoordinate(); - final float bottom = Edge.BOTTOM.getCoordinate(); - final float lateralOffset = (mCornerThickness - mBorderThickness) / 2f; - final float startOffset = mCornerThickness - (mBorderThickness / 2f); - canvas.drawLine(left - lateralOffset, top - startOffset, left - lateralOffset, top + mCornerLength, mCornerPaint); - canvas.drawLine(left - startOffset, top - lateralOffset, left + mCornerLength, top - lateralOffset, mCornerPaint); - canvas.drawLine(right + lateralOffset, top - startOffset, right + lateralOffset, top + mCornerLength, mCornerPaint); - canvas.drawLine(right + startOffset, top - lateralOffset, right - mCornerLength, top - lateralOffset, mCornerPaint); - canvas.drawLine(left - lateralOffset, bottom + startOffset, left - lateralOffset, bottom - mCornerLength, mCornerPaint); - canvas.drawLine(left - startOffset, bottom + lateralOffset, left + mCornerLength, bottom + lateralOffset, mCornerPaint); - canvas.drawLine(right + lateralOffset, bottom + startOffset, right + lateralOffset, bottom - mCornerLength, mCornerPaint); - canvas.drawLine(right + startOffset, bottom + lateralOffset, right - mCornerLength, bottom + lateralOffset, mCornerPaint); - } - - private boolean shouldGuidelinesBeShown() { - return ((mGuidelinesMode == GUIDELINES_ON) - || ((mGuidelinesMode == GUIDELINES_ON_TOUCH) && (mPressedHandle != null))); - } - - private float getTargetAspectRatio() { - return mAspectRatioX / (float) mAspectRatioY; - } - - private void onActionDown(float x, float y) { - final float left = Edge.LEFT.getCoordinate(); - final float top = Edge.TOP.getCoordinate(); - final float right = Edge.RIGHT.getCoordinate(); - final float bottom = Edge.BOTTOM.getCoordinate(); - mPressedHandle = HandleUtil.getPressedHandle(x, y, left, top, right, bottom, mHandleRadius); - if (mPressedHandle != null) { - HandleUtil.getOffset(mPressedHandle, x, y, left, top, right, bottom, mTouchOffset); - invalidate(); - } - } - - private void onActionUp() { - if (mPressedHandle != null) { - mPressedHandle = null; - invalidate(); - } - } - - private void onActionMove(float x, float y) { - if (mPressedHandle == null) { - return; - } - x += mTouchOffset.x; - y += mTouchOffset.y; - if (mFixAspectRatio) { - mPressedHandle.updateCropWindow(x, y, getTargetAspectRatio(), mBitmapRect, mSnapRadius); - } else { - mPressedHandle.updateCropWindow(x, y, mBitmapRect, mSnapRadius); - } - invalidate(); - } - } - - public static class PaintUtil { - public static Paint newBorderPaint(android.content.res.Resources resources) { - final Paint paint = new Paint(); - paint.setStyle(Paint.Style.STROKE); - paint.setStrokeWidth(3); - paint.setColor(Color.parseColor("#AAFFFFFF")); - return paint; - } - - public static Paint newGuidelinePaint(android.content.res.Resources resources) { - final Paint paint = new Paint(); - paint.setStyle(Paint.Style.STROKE); - paint.setStrokeWidth(1); - paint.setColor(Color.parseColor("#AAFFFFFF")); - return paint; - } - - public static Paint newSurroundingAreaOverlayPaint(android.content.res.Resources resources) { - final Paint paint = new Paint(); - paint.setStyle(Paint.Style.FILL); - paint.setColor(Color.parseColor("#B0000000")); - return paint; - } - - public static Paint newCornerPaint(android.content.res.Resources resources) { - final Paint paint = new Paint(); - paint.setStyle(Paint.Style.STROKE); - paint.setStrokeWidth(5); - paint.setColor(Color.parseColor("#FFFFFF")); - return paint; - } - } - - public static class MathUtil { - public static float calculateDistance(float x1, float y1, float x2, float y2) { - final float side1 = x2 - x1; - final float side2 = y2 - y1; - return (float) Math.sqrt(side1 * side1 + side2 * side2); - } - } - - public static class HandleUtil { - public static Handle getPressedHandle(float x, - float y, - float left, - float top, - float right, - float bottom, - float targetRadius) { - Handle closestHandle = null; - float closestDistance = Float.POSITIVE_INFINITY; - final float distanceToTopLeft = MathUtil.calculateDistance(x, y, left, top); - if (distanceToTopLeft < closestDistance) { - closestDistance = distanceToTopLeft; - closestHandle = Handle.TOP_LEFT; - } - final float distanceToTopRight = MathUtil.calculateDistance(x, y, right, top); - if (distanceToTopRight < closestDistance) { - closestDistance = distanceToTopRight; - closestHandle = Handle.TOP_RIGHT; - } - final float distanceToBottomLeft = MathUtil.calculateDistance(x, y, left, bottom); - if (distanceToBottomLeft < closestDistance) { - closestDistance = distanceToBottomLeft; - closestHandle = Handle.BOTTOM_LEFT; - } - final float distanceToBottomRight = MathUtil.calculateDistance(x, y, right, bottom); - if (distanceToBottomRight < closestDistance) { - closestDistance = distanceToBottomRight; - closestHandle = Handle.BOTTOM_RIGHT; - } - if (closestDistance <= targetRadius) { - return closestHandle; - } - if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, top, targetRadius)) { - return Handle.TOP; - } else if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, bottom, targetRadius)) { - return Handle.BOTTOM; - } else if (HandleUtil.isInVerticalTargetZone(x, y, left, top, bottom, targetRadius)) { - return Handle.LEFT; - } else if (HandleUtil.isInVerticalTargetZone(x, y, right, top, bottom, targetRadius)) { - return Handle.RIGHT; - } - if (isWithinBounds(x, y, left, top, right, bottom)) { - return Handle.CENTER; - } - return null; - } - - public static void getOffset(Handle handle, - float x, - float y, - float left, - float top, - float right, - float bottom, - PointF touchOffsetOutput) { - float touchOffsetX = 0; - float touchOffsetY = 0; - switch (handle) { - case TOP_LEFT: - touchOffsetX = left - x; - touchOffsetY = top - y; - break; - case TOP_RIGHT: - touchOffsetX = right - x; - touchOffsetY = top - y; - break; - case BOTTOM_LEFT: - touchOffsetX = left - x; - touchOffsetY = bottom - y; - break; - case BOTTOM_RIGHT: - touchOffsetX = right - x; - touchOffsetY = bottom - y; - break; - case LEFT: - touchOffsetX = left - x; - touchOffsetY = 0; - break; - case TOP: - touchOffsetX = 0; - touchOffsetY = top - y; - break; - case RIGHT: - touchOffsetX = right - x; - touchOffsetY = 0; - break; - case BOTTOM: - touchOffsetX = 0; - touchOffsetY = bottom - y; - break; - case CENTER: - final float centerX = (right + left) / 2; - final float centerY = (top + bottom) / 2; - touchOffsetX = centerX - x; - touchOffsetY = centerY - y; - break; - } - touchOffsetOutput.x = touchOffsetX; - touchOffsetOutput.y = touchOffsetY; - } - - private static boolean isInHorizontalTargetZone(float x, - float y, - float handleXStart, - float handleXEnd, - float handleY, - float targetRadius) { - return (x > handleXStart && x < handleXEnd && Math.abs(y - handleY) <= targetRadius); - } - - private static boolean isInVerticalTargetZone(float x, - float y, - float handleX, - float handleYStart, - float handleYEnd, - float targetRadius) { - return (Math.abs(x - handleX) <= targetRadius && y > handleYStart && y < handleYEnd); - } - - private static boolean isWithinBounds(float x, float y, float left, float top, float right, float bottom) { - return x >= left && x <= right && y >= top && y <= bottom; - } - } - - public static class AspectRatioUtil { - public static float calculateAspectRatio(float left, float top, float right, float bottom) { - final float width = right - left; - final float height = bottom - top; - return width / height; - } - - public static float calculateAspectRatio(RectF rect) { - return rect.width() / rect.height(); - } - - public static float calculateLeft(float top, float right, float bottom, float targetAspectRatio) { - final float height = bottom - top; - return right - (targetAspectRatio * height); - } - - public static float calculateTop(float left, float right, float bottom, float targetAspectRatio) { - final float width = right - left; - return bottom - (width / targetAspectRatio); - } - - public static float calculateRight(float left, float top, float bottom, float targetAspectRatio) { - final float height = bottom - top; - return (targetAspectRatio * height) + left; - } - - public static float calculateBottom(float left, float top, float right, float targetAspectRatio) { - final float width = right - left; - return (width / targetAspectRatio) + top; - } - - public static float calculateWidth(float height, float targetAspectRatio) { - return targetAspectRatio * height; - } - - public static float calculateHeight(float width, float targetAspectRatio) { - return width / targetAspectRatio; - } - } - - static abstract class HandleHelper { - private static final float UNFIXED_ASPECT_RATIO_CONSTANT = 1; - private Edge mHorizontalEdge; - private Edge mVerticalEdge; - private EdgePair mActiveEdges; - - HandleHelper(Edge horizontalEdge, Edge verticalEdge) { - mHorizontalEdge = horizontalEdge; - mVerticalEdge = verticalEdge; - mActiveEdges = new EdgePair(mHorizontalEdge, mVerticalEdge); - } - - void updateCropWindow(float x, - float y, - RectF imageRect, - float snapRadius) { - final EdgePair activeEdges = getActiveEdges(); - final Edge primaryEdge = activeEdges.primary; - final Edge secondaryEdge = activeEdges.secondary; - if (primaryEdge != null) - primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT); - if (secondaryEdge != null) - secondaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT); - } - - abstract void updateCropWindow(float x, - float y, - float targetAspectRatio, - RectF imageRect, - float snapRadius); - - EdgePair getActiveEdges() { - return mActiveEdges; - } - - EdgePair getActiveEdges(float x, float y, float targetAspectRatio) { - final float potentialAspectRatio = getAspectRatio(x, y); - if (potentialAspectRatio > targetAspectRatio) { - mActiveEdges.primary = mVerticalEdge; - mActiveEdges.secondary = mHorizontalEdge; - } else { - mActiveEdges.primary = mHorizontalEdge; - mActiveEdges.secondary = mVerticalEdge; - } - return mActiveEdges; - } - - private float getAspectRatio(float x, float y) { - final float left = (mVerticalEdge == Edge.LEFT) ? x : Edge.LEFT.getCoordinate(); - final float top = (mHorizontalEdge == Edge.TOP) ? y : Edge.TOP.getCoordinate(); - final float right = (mVerticalEdge == Edge.RIGHT) ? x : Edge.RIGHT.getCoordinate(); - final float bottom = (mHorizontalEdge == Edge.BOTTOM) ? y : Edge.BOTTOM.getCoordinate(); - return AspectRatioUtil.calculateAspectRatio(left, top, right, bottom); - } - } - - static class HorizontalHandleHelper extends HandleHelper { - private Edge mEdge; - - HorizontalHandleHelper(Edge edge) { - super(edge, null); - mEdge = edge; - } - - @Override - void updateCropWindow(float x, - float y, - float targetAspectRatio, - RectF imageRect, - float snapRadius) { - mEdge.adjustCoordinate(x, y, imageRect, snapRadius, targetAspectRatio); - float left = Edge.LEFT.getCoordinate(); - float right = Edge.RIGHT.getCoordinate(); - final float targetWidth = AspectRatioUtil.calculateWidth(Edge.getHeight(), targetAspectRatio); - final float difference = targetWidth - Edge.getWidth(); - final float halfDifference = difference / 2; - left -= halfDifference; - right += halfDifference; - Edge.LEFT.setCoordinate(left); - Edge.RIGHT.setCoordinate(right); - if (Edge.LEFT.isOutsideMargin(imageRect, snapRadius) - && !mEdge.isNewRectangleOutOfBounds(Edge.LEFT, imageRect, targetAspectRatio)) { - final float offset = Edge.LEFT.snapToRect(imageRect); - Edge.RIGHT.offset(-offset); - mEdge.adjustCoordinate(targetAspectRatio); - } - if (Edge.RIGHT.isOutsideMargin(imageRect, snapRadius) - && !mEdge.isNewRectangleOutOfBounds(Edge.RIGHT, imageRect, targetAspectRatio)) { - final float offset = Edge.RIGHT.snapToRect(imageRect); - Edge.LEFT.offset(-offset); - mEdge.adjustCoordinate(targetAspectRatio); - } - } - } - - static class VerticalHandleHelper extends HandleHelper { - private Edge mEdge; - - VerticalHandleHelper(Edge edge) { - super(null, edge); - mEdge = edge; - } - - @Override - void updateCropWindow(float x, - float y, - float targetAspectRatio, - RectF imageRect, - float snapRadius) { - mEdge.adjustCoordinate(x, y, imageRect, snapRadius, targetAspectRatio); - float top = Edge.TOP.getCoordinate(); - float bottom = Edge.BOTTOM.getCoordinate(); - final float targetHeight = AspectRatioUtil.calculateHeight(Edge.getWidth(), targetAspectRatio); - final float difference = targetHeight - Edge.getHeight(); - final float halfDifference = difference / 2; - top -= halfDifference; - bottom += halfDifference; - Edge.TOP.setCoordinate(top); - Edge.BOTTOM.setCoordinate(bottom); - if (Edge.TOP.isOutsideMargin(imageRect, snapRadius) - && !mEdge.isNewRectangleOutOfBounds(Edge.TOP, imageRect, targetAspectRatio)) { - final float offset = Edge.TOP.snapToRect(imageRect); - Edge.BOTTOM.offset(-offset); - mEdge.adjustCoordinate(targetAspectRatio); - } - if (Edge.BOTTOM.isOutsideMargin(imageRect, snapRadius) - && !mEdge.isNewRectangleOutOfBounds(Edge.BOTTOM, imageRect, targetAspectRatio)) { - final float offset = Edge.BOTTOM.snapToRect(imageRect); - Edge.TOP.offset(-offset); - mEdge.adjustCoordinate(targetAspectRatio); - } - } - } - - static class CenterHandleHelper extends HandleHelper { - CenterHandleHelper() { - super(null, null); - } - - @Override - void updateCropWindow(float x, - float y, - RectF imageRect, - float snapRadius) { - float left = Edge.LEFT.getCoordinate(); - float top = Edge.TOP.getCoordinate(); - float right = Edge.RIGHT.getCoordinate(); - float bottom = Edge.BOTTOM.getCoordinate(); - final float currentCenterX = (left + right) / 2; - final float currentCenterY = (top + bottom) / 2; - final float offsetX = x - currentCenterX; - final float offsetY = y - currentCenterY; - Edge.LEFT.offset(offsetX); - Edge.TOP.offset(offsetY); - Edge.RIGHT.offset(offsetX); - Edge.BOTTOM.offset(offsetY); - if (Edge.LEFT.isOutsideMargin(imageRect, snapRadius)) { - final float offset = Edge.LEFT.snapToRect(imageRect); - Edge.RIGHT.offset(offset); - } else if (Edge.RIGHT.isOutsideMargin(imageRect, snapRadius)) { - final float offset = Edge.RIGHT.snapToRect(imageRect); - Edge.LEFT.offset(offset); - } - if (Edge.TOP.isOutsideMargin(imageRect, snapRadius)) { - final float offset = Edge.TOP.snapToRect(imageRect); - Edge.BOTTOM.offset(offset); - } else if (Edge.BOTTOM.isOutsideMargin(imageRect, snapRadius)) { - final float offset = Edge.BOTTOM.snapToRect(imageRect); - Edge.TOP.offset(offset); - } - } - - @Override - void updateCropWindow(float x, - float y, - float targetAspectRatio, - RectF imageRect, - float snapRadius) { - - updateCropWindow(x, y, imageRect, snapRadius); - } - } - - static class CornerHandleHelper extends HandleHelper { - CornerHandleHelper(Edge horizontalEdge, Edge verticalEdge) { - super(horizontalEdge, verticalEdge); - } - - @Override - void updateCropWindow(float x, - float y, - float targetAspectRatio, - RectF imageRect, - float snapRadius) { - final EdgePair activeEdges = getActiveEdges(x, y, targetAspectRatio); - final Edge primaryEdge = activeEdges.primary; - final Edge secondaryEdge = activeEdges.secondary; - primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, targetAspectRatio); - secondaryEdge.adjustCoordinate(targetAspectRatio); - if (secondaryEdge.isOutsideMargin(imageRect, snapRadius)) { - secondaryEdge.snapToRect(imageRect); - primaryEdge.adjustCoordinate(targetAspectRatio); - } - } - } - - public static class EdgePair { - public Edge primary; - public Edge secondary; - - public EdgePair(Edge edge1, Edge edge2) { - primary = edge1; - secondary = edge2; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/DaeditActivity.java b/app/src/main/java/tw/music/streamer/DaeditActivity.java deleted file mode 100644 index 000dd19..0000000 --- a/app/src/main/java/tw/music/streamer/DaeditActivity.java +++ /dev/null @@ -1,793 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.text.InputType; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.ArrayAdapter; -import android.widget.BaseAdapter; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; - -public class DaeditActivity extends AppCompatActivity { - - - private FloatingActionButton _fab; - - private ArrayList> dataMap = new ArrayList<>(); - private ArrayList dialog_list = new ArrayList<>(); - private ArrayList childkey = new ArrayList<>(); - private ArrayList> theme_map = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private ImageView imageview_back; - private TextView textview_title; - private ListView listview1; - - private SharedPreferences data; - private AlertDialog.Builder dialog; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.daedit); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - _fab = findViewById(R.id._fab); - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - imageview_back = findViewById(R.id.imageview_back); - textview_title = findViewById(R.id.textview_title); - listview1 = findViewById(R.id.listview1); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - dialog = new AlertDialog.Builder(this); - - imageview_back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - _fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - double _tmpNum = 0; - childkey.clear(); - for (int _repeat11 = 0; _repeat11 < dataMap.size(); _repeat11++) { - if (dataMap.get((int) _tmpNum).get("type").toString().equals("key")) { - childkey.add(dataMap.get((int) _tmpNum).get("key").toString()); - } - _tmpNum++; - } - childkey.add("Add new childkey"); - dialog.setCancelable(false); - dialog.setAdapter(new ArrayAdapter(DaeditActivity.this, android.R.layout.simple_list_item_1, childkey), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dia, int _pos_dialog) { - _resetDialog(); - if (_pos_dialog == (childkey.size() - 1)) { - _customSnack("Not implemented yet.", 2); - } else { - _add(childkey.get(_pos_dialog)); - } - } - }); - dialog.create().show(); - } - }); - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - _loadTheme(); - textview_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - dialog_list.add("Edit"); - dialog_list.add("Delete"); - dialog_list.add("Cancel"); - _retrieveData(); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _retrieveData() { - dataMap.clear(); - { - HashMap _item = new HashMap<>(); - _item.put("key", "teamdata"); - dataMap.add(_item); - } - - dataMap.get(dataMap.size() - 1).put("type", "key"); - Map _allEntries = data.getAll(); - for (Map.Entry _entry : _allEntries.entrySet()) { - { - HashMap _item = new HashMap<>(); - _item.put("key", _entry.getKey()); - dataMap.add(_item); - } - - dataMap.get(dataMap.size() - 1).put("value", _entry.getValue()); - dataMap.get(dataMap.size() - 1).put("type", "subkey"); - dataMap.get(dataMap.size() - 1).put("childkey", "teamdata"); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(dataMap)); - listview1.setSelectionFromTop(_index, _top); - } - - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - - private void _resetDialog() { - dialog = null; - dialog = new AlertDialog.Builder(this); - } - - - private void _add(final String _childKey) { - LinearLayout mylayout = new LinearLayout(DaeditActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(DaeditActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Key"); - dialog.setCancelable(false); - dialog.setTitle("Add subkey"); - dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - _resetDialog(); - _add2(_childKey, myedittext.getText().toString()); - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - _resetDialog(); - } - }); - dialog.create().show(); - } - - - private void _add2(final String _childKey, final String _key) { - LinearLayout mylayout = new LinearLayout(DaeditActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(DaeditActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Value"); - dialog.setCancelable(false); - dialog.setTitle("Add subkey"); - dialog.setPositiveButton("Set", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - _resetDialog(); - data = getSharedPreferences(_childKey, Activity.MODE_PRIVATE); - data.edit().putString(_key, myedittext.getText().toString()).commit(); - _retrieveData(); - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - _resetDialog(); - } - }); - dialog.create().show(); - } - - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview_back); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - } - _fab.setBackgroundTintList(android.content.res.ColorStateList.valueOf(Color.parseColor(theme_map.get(0).get("colorButton").toString()))); - _fab.setRippleColor(Color.parseColor(theme_map.get(0).get("colorRipple").toString())); - _fab.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString())); - textview_title.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview_back.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - - private void _rippleLib() { - } - - public void drawableclass() { - } - - private void _abandonFocus() { - View _tmpView = this.getCurrentFocus(); - if (_tmpView != null) { - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(_tmpView.getWindowToken(), 0); - } - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public class Listview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Listview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.daeditlayout, null); - } - - final LinearLayout linear1 = _v.findViewById(R.id.linear1); - final ImageView imageview2 = _v.findViewById(R.id.imageview2); - final ImageView imageview1 = _v.findViewById(R.id.imageview1); - final TextView textview1 = _v.findViewById(R.id.textview1); - - if (_data.get(_position).get("type").toString().equals("key")) { - textview1.setText(_data.get(_position).get("key").toString()); - imageview1.setImageResource(R.drawable.ic_folder); - } - if (_data.get(_position).get("type").toString().equals("subkey")) { - textview1.setText(_data.get(_position).get("key").toString().concat(": ".concat(_data.get(_position).get("value").toString()))); - imageview1.setImageResource(R.drawable.ic_file); - } - if (_data.get(_position).containsKey("childkey")) { - imageview2.setVisibility(View.VISIBLE); - } else { - imageview2.setVisibility(View.GONE); - } - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview2.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - linear1.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - linear1.setClickable(true); - linear1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - dialog.setCancelable(false); - dialog.setTitle(dataMap.get(_position).get("key").toString()); - if (dataMap.get(_position).get("type").toString().equals("key")) { - String _tmpKeys = ""; - double _tmpNum = 0; - for (int _repeat73 = 0; _repeat73 < dataMap.size(); _repeat73++) { - if (dataMap.get((int) _tmpNum).get("type").toString().equals("subkey")) { - if (dataMap.get((int) _tmpNum).get("childkey").toString().equals(dataMap.get(_position).get("key").toString())) { - _tmpKeys = _tmpKeys.concat(dataMap.get((int) _tmpNum).get("key").toString().concat("\n")); - } - } - if (_tmpNum == (dataMap.size() - 1)) { - dialog.setMessage(_tmpKeys); - } - _tmpNum++; - } - } else { - if (dataMap.get(_position).get("type").toString().equals("subkey")) { - dialog.setMessage(dataMap.get(_position).get("value").toString()); - } - } - dialog.setPositiveButton("Close", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - dialog.create().show(); - } - }); - linear1.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _vlol) { - dialog.setCancelable(false); - dialog.setAdapter(new ArrayAdapter(DaeditActivity.this, android.R.layout.simple_list_item_1, dialog_list), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dia, int _pos_dialog) { - _resetDialog(); - if (_pos_dialog == 0) { - if (dataMap.get(_position).get("type").toString().equals("key")) { - _customSnack("Not implemented yet.", 2); - } else { - if (dataMap.get(_position).get("type").toString().equals("subkey")) { - LinearLayout mylayout = new LinearLayout(DaeditActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(DaeditActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setText(dataMap.get(_position).get("value").toString()); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Value"); - dialog.setCancelable(false); - dialog.setTitle("Change value"); - dialog.setPositiveButton("Set", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - _resetDialog(); - data = getSharedPreferences(dataMap.get(_position).get("childkey").toString(), Activity.MODE_PRIVATE); - data.edit().putString(dataMap.get(_position).get("key").toString(), myedittext.getText().toString()).commit(); - _retrieveData(); - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - _resetDialog(); - } - }); - dialog.create().show(); - } - } - } else { - if (_pos_dialog == 1) { - if (dataMap.get(_position).get("type").toString().equals("key")) { - data = getSharedPreferences(dataMap.get(_position).get("key").toString(), Activity.MODE_PRIVATE); - data.edit().clear().commit(); - _retrieveData(); - } else { - if (dataMap.get(_position).get("type").toString().equals("subkey")) { - data = getSharedPreferences(dataMap.get(_position).get("childkey").toString(), Activity.MODE_PRIVATE); - data.edit().remove(dataMap.get(_position).get("key").toString()).commit(); - _retrieveData(); - } - } - } else { - if (_pos_dialog == 2) { - - } - } - } - } - }); - dialog.create().show(); - return true; - } - }); - - return _v; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/DebugActivity.java b/app/src/main/java/tw/music/streamer/DebugActivity.java deleted file mode 100644 index e1d1a06..0000000 --- a/app/src/main/java/tw/music/streamer/DebugActivity.java +++ /dev/null @@ -1,362 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.view.Window; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; - -public class DebugActivity extends AppCompatActivity { - - private Timer _timer = new Timer(); - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - - private HashMap mapvar = new HashMap<>(); - private double count = 0; - - private LinearLayout linear1; - private LinearLayout linear3; - private TextView textview4; - private TextView textview2; - private ScrollView vscroll1; - private LinearLayout linear2; - private ImageView imageview1; - private TextView textview1; - private TextView textview3; - - private SharedPreferences data; - private Calendar cal = Calendar.getInstance(); - private DatabaseReference fb_error = _firebase.getReference("fb/crashdata"); - private ChildEventListener _fb_error_child_listener; - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private TimerTask timer; - private Intent intent = new Intent(); - private android.content.pm.PackageInfo packageInfo; - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.debug); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear3 = findViewById(R.id.linear3); - textview4 = findViewById(R.id.textview4); - textview2 = findViewById(R.id.textview2); - vscroll1 = findViewById(R.id.vscroll1); - linear2 = findViewById(R.id.linear2); - imageview1 = findViewById(R.id.imageview1); - textview1 = findViewById(R.id.textview1); - textview3 = findViewById(R.id.textview3); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - Auth = FirebaseAuth.getInstance(); - - textview2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - try { - timer.cancel(); - } catch (Exception _e) { - } - intent.setClass(getApplicationContext(), DaeditActivity.class); - startActivity(intent); - finish(); - } - }); - - _fb_error_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - fb_error.addChildEventListener(_fb_error_child_listener); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - setTheme(android.R.style.ThemeOverlay_Material_Dark); - try { - packageInfo = DebugActivity.this.getPackageManager().getPackageInfo(getPackageName(), 0); - } catch (Exception _e) { - } - textview3.setTextIsSelectable(true); - setTitle("DebugActivity"); - cal = Calendar.getInstance(); - mapvar = new HashMap<>(); - mapvar.put("error", getIntent().getStringExtra("error")); - mapvar.put("user", FirebaseAuth.getInstance().getCurrentUser().getEmail()); - mapvar.put("android", Build.VERSION.RELEASE); - mapvar.put("versionCode", Integer.toString(packageInfo.versionCode)); - mapvar.put("versionName", packageInfo.versionName); - mapvar.put("id", Build.ID); - mapvar.put("product", Build.PRODUCT); - mapvar.put("serial", Build.SERIAL); - mapvar.put("time", String.valueOf(cal.getTimeInMillis())); - mapvar.put("package", getApplicationContext().getPackageName()); - fb_error.push().updateChildren(mapvar); - data.edit().putString("errorLog", data.getString("errorLog", "").concat("[".concat(new SimpleDateFormat("E, dd MMM yyyy HH:mm").format(cal.getTime()).concat("] ".concat(getIntent().getStringExtra("error").concat("\n\n")))))).commit(); - textview3.setText(getIntent().getStringExtra("error")); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - imageview1.setColorFilter(0xFFF44336, PorterDuff.Mode.MULTIPLY); - if (data.getString("errorCountdown", "").contains("-")) { - count = 30; - } else { - try { - count = Double.parseDouble(data.getString("errorCountdown", "")); - } catch (Exception _e) { - count = 30; - } - } - textview4.setText("Restarting on... ".concat(String.valueOf((long) (count)))); - timer = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - count--; - if (count > 0) { - textview4.setText("Restarting on... ".concat(String.valueOf((long) (count)))); - } else { - intent.setClass(getApplicationContext(), MainActivity.class); - startActivity(intent); - finish(); - } - } - }); - } - }; - _timer.scheduleAtFixedRate(timer, 1000, 1000); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - _DarkMode(); - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _DarkMode() { - int nightModeFlags = getResources().getConfiguration().uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK; - if (nightModeFlags == android.content.res.Configuration.UI_MODE_NIGHT_YES) { - textview1.setTextColor(0xFFFFFFFF); - textview4.setTextColor(0xFFFFFFFF); - linear1.setBackgroundColor(0xFF252525); - getWindow().setStatusBarColor(Color.parseColor("#252525")); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(0); - } - _customNav("#252525"); - } else { - textview1.setTextColor(0xFF000000); - textview4.setTextColor(0xFF000000); - linear1.setBackgroundColor(0xFFFFFFFF); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().setStatusBarColor(Color.parseColor("#FFFFFF")); - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } else { - getWindow().setStatusBarColor(Color.parseColor("#BDBDBD")); - } - _customNav("#FFFFFF"); - } - } - - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - -} diff --git a/app/src/main/java/tw/music/streamer/FileUtil.java b/app/src/main/java/tw/music/streamer/FileUtil.java deleted file mode 100644 index aa2edb4..0000000 --- a/app/src/main/java/tw/music/streamer/FileUtil.java +++ /dev/null @@ -1,604 +0,0 @@ -package tw.music.streamer; - -import android.content.ContentResolver; -import android.content.ContentUris; -import android.content.Context; -import android.database.Cursor; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.ColorFilter; -import android.graphics.ColorMatrix; -import android.graphics.ColorMatrixColorFilter; -import android.graphics.LightingColorFilter; -import android.graphics.Matrix; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.media.ExifInterface; -import android.net.Uri; -import android.os.Environment; -import android.provider.DocumentsContract; -import android.provider.MediaStore; -import android.text.TextUtils; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.net.URLDecoder; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; - -public class FileUtil { - - private static void createNewFile(String path) { - int lastSep = path.lastIndexOf(File.separator); - if (lastSep > 0) { - String dirPath = path.substring(0, lastSep); - makeDir(dirPath); - } - - File file = new File(path); - - try { - if (!file.exists()) - file.createNewFile(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public static String readFile(String path) { - createNewFile(path); - - StringBuilder sb = new StringBuilder(); - FileReader fr = null; - try { - fr = new FileReader(new File(path)); - - char[] buff = new char[1024]; - int length = 0; - - while ((length = fr.read(buff)) > 0) { - sb.append(new String(buff, 0, length)); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (fr != null) { - try { - fr.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - return sb.toString(); - } - - public static void writeFile(String path, String str) { - createNewFile(path); - FileWriter fileWriter = null; - - try { - fileWriter = new FileWriter(new File(path), false); - fileWriter.write(str); - fileWriter.flush(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - try { - if (fileWriter != null) - fileWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public static void copyFile(String sourcePath, String destPath) { - if (!isExistFile(sourcePath)) return; - createNewFile(destPath); - - FileInputStream fis = null; - FileOutputStream fos = null; - - try { - fis = new FileInputStream(sourcePath); - fos = new FileOutputStream(destPath, false); - - byte[] buff = new byte[1024]; - int length = 0; - - while ((length = fis.read(buff)) > 0) { - fos.write(buff, 0, length); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (fis != null) { - try { - fis.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static void moveFile(String sourcePath, String destPath) { - copyFile(sourcePath, destPath); - deleteFile(sourcePath); - } - - public static void deleteFile(String path) { - File file = new File(path); - - if (!file.exists()) return; - - if (file.isFile()) { - file.delete(); - return; - } - - File[] fileArr = file.listFiles(); - - if (fileArr != null) { - for (File subFile : fileArr) { - if (subFile.isDirectory()) { - deleteFile(subFile.getAbsolutePath()); - } - - if (subFile.isFile()) { - subFile.delete(); - } - } - } - - file.delete(); - } - - public static boolean isExistFile(String path) { - File file = new File(path); - return file.exists(); - } - - public static void makeDir(String path) { - if (!isExistFile(path)) { - File file = new File(path); - file.mkdirs(); - } - } - - public static void listDir(String path, ArrayList list) { - File dir = new File(path); - if (!dir.exists() || dir.isFile()) return; - - File[] listFiles = dir.listFiles(); - if (listFiles == null || listFiles.length <= 0) return; - - if (list == null) return; - list.clear(); - for (File file : listFiles) { - list.add(file.getAbsolutePath()); - } - } - - public static boolean isDirectory(String path) { - if (!isExistFile(path)) return false; - return new File(path).isDirectory(); - } - - public static boolean isFile(String path) { - if (!isExistFile(path)) return false; - return new File(path).isFile(); - } - - public static long getFileLength(String path) { - if (!isExistFile(path)) return 0; - return new File(path).length(); - } - - public static String getExternalStorageDir() { - return Environment.getExternalStorageDirectory().getAbsolutePath(); - } - - public static String getPackageDataDir(Context context) { - return context.getExternalFilesDir(null).getAbsolutePath(); - } - - public static String getPublicDir(String type) { - return Environment.getExternalStoragePublicDirectory(type).getAbsolutePath(); - } - - public static String convertUriToFilePath(final Context context, final Uri uri) { - String path = null; - if (DocumentsContract.isDocumentUri(context, uri)) { - if (isExternalStorageDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - - if ("primary".equalsIgnoreCase(type)) { - path = Environment.getExternalStorageDirectory() + "/" + split[1]; - } - } else if (isDownloadsDocument(uri)) { - final String id = DocumentsContract.getDocumentId(uri); - - if (!TextUtils.isEmpty(id)) { - if (id.startsWith("raw:")) { - return id.replaceFirst("raw:", ""); - } - } - - final Uri contentUri = ContentUris - .withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); - - path = getDataColumn(context, contentUri, null, null); - } else if (isMediaDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - - Uri contentUri = null; - if ("image".equals(type)) { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; - } else if ("video".equals(type)) { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; - } else if ("audio".equals(type)) { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; - } - - final String selection = MediaStore.Audio.Media._ID + "=?"; - final String[] selectionArgs = new String[]{ - split[1] - }; - - path = getDataColumn(context, contentUri, selection, selectionArgs); - } - } else if (ContentResolver.SCHEME_CONTENT.equalsIgnoreCase(uri.getScheme())) { - path = getDataColumn(context, uri, null, null); - } else if (ContentResolver.SCHEME_FILE.equalsIgnoreCase(uri.getScheme())) { - path = uri.getPath(); - } - - if (path != null) { - try { - return URLDecoder.decode(path, "UTF-8"); - } catch (Exception e) { - return null; - } - } - return null; - } - - private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { - Cursor cursor = null; - - final String column = MediaStore.Images.Media.DATA; - final String[] projection = { - column - }; - - try { - cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); - if (cursor != null && cursor.moveToFirst()) { - final int column_index = cursor.getColumnIndexOrThrow(column); - return cursor.getString(column_index); - } - } catch (Exception e) { - - } finally { - if (cursor != null) { - cursor.close(); - } - } - return null; - } - - - private static boolean isExternalStorageDocument(Uri uri) { - return "com.android.externalstorage.documents".equals(uri.getAuthority()); - } - - private static boolean isDownloadsDocument(Uri uri) { - return "com.android.providers.downloads.documents".equals(uri.getAuthority()); - } - - private static boolean isMediaDocument(Uri uri) { - return "com.android.providers.media.documents".equals(uri.getAuthority()); - } - - private static void saveBitmap(Bitmap bitmap, String destPath) { - FileOutputStream out = null; - FileUtil.createNewFile(destPath); - try { - out = new FileOutputStream(new File(destPath)); - bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); - } catch (Exception e) { - e.printStackTrace(); - } finally { - try { - if (out != null) { - out.close(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - } - - public static Bitmap getScaledBitmap(String path, int max) { - Bitmap src = BitmapFactory.decodeFile(path); - - int width = src.getWidth(); - int height = src.getHeight(); - float rate = 0.0f; - - if (width > height) { - rate = max / (float) width; - height = (int) (height * rate); - width = max; - } else { - rate = max / (float) height; - width = (int) (width * rate); - height = max; - } - - return Bitmap.createScaledBitmap(src, width, height, true); - } - - public static int calculateInSampleSize(BitmapFactory.Options options, int reqWidth, int reqHeight) { - final int width = options.outWidth; - final int height = options.outHeight; - int inSampleSize = 1; - - if (height > reqHeight || width > reqWidth) { - final int halfHeight = height / 2; - final int halfWidth = width / 2; - - while ((halfHeight / inSampleSize) >= reqHeight && (halfWidth / inSampleSize) >= reqWidth) { - inSampleSize *= 2; - } - } - - return inSampleSize; - } - - public static Bitmap decodeSampleBitmapFromPath(String path, int reqWidth, int reqHeight) { - final BitmapFactory.Options options = new BitmapFactory.Options(); - options.inJustDecodeBounds = true; - BitmapFactory.decodeFile(path, options); - - options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight); - - options.inJustDecodeBounds = false; - return BitmapFactory.decodeFile(path, options); - } - - public static void resizeBitmapFileRetainRatio(String fromPath, String destPath, int max) { - if (!isExistFile(fromPath)) return; - Bitmap bitmap = getScaledBitmap(fromPath, max); - saveBitmap(bitmap, destPath); - } - - public static void resizeBitmapFileToSquare(String fromPath, String destPath, int max) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Bitmap bitmap = Bitmap.createScaledBitmap(src, max, max, true); - saveBitmap(bitmap, destPath); - } - - public static void resizeBitmapFileToCircle(String fromPath, String destPath) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), - src.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - final int color = 0xff424242; - final Paint paint = new Paint(); - final Rect rect = new Rect(0, 0, src.getWidth(), src.getHeight()); - - paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(color); - canvas.drawCircle(src.getWidth() / 2, src.getHeight() / 2, - src.getWidth() / 2, paint); - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(src, rect, rect, paint); - - saveBitmap(bitmap, destPath); - } - - public static void resizeBitmapFileWithRoundedBorder(String fromPath, String destPath, int pixels) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src - .getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - final int color = 0xff424242; - final Paint paint = new Paint(); - final Rect rect = new Rect(0, 0, src.getWidth(), src.getHeight()); - final RectF rectF = new RectF(rect); - final float roundPx = pixels; - - paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(color); - canvas.drawRoundRect(rectF, roundPx, roundPx, paint); - - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(src, rect, rect, paint); - - saveBitmap(bitmap, destPath); - } - - public static void cropBitmapFileFromCenter(String fromPath, String destPath, int w, int h) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - - int width = src.getWidth(); - int height = src.getHeight(); - - if (width < w && height < h) - return; - - int x = 0; - int y = 0; - - if (width > w) - x = (width - w) / 2; - - if (height > h) - y = (height - h) / 2; - - int cw = w; - int ch = h; - - if (w > width) - cw = width; - - if (h > height) - ch = height; - - Bitmap bitmap = Bitmap.createBitmap(src, x, y, cw, ch); - saveBitmap(bitmap, destPath); - } - - public static void rotateBitmapFile(String fromPath, String destPath, float angle) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Matrix matrix = new Matrix(); - matrix.postRotate(angle); - Bitmap bitmap = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true); - saveBitmap(bitmap, destPath); - } - - public static void scaleBitmapFile(String fromPath, String destPath, float x, float y) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Matrix matrix = new Matrix(); - matrix.postScale(x, y); - - int w = src.getWidth(); - int h = src.getHeight(); - - Bitmap bitmap = Bitmap.createBitmap(src, 0, 0, w, h, matrix, true); - saveBitmap(bitmap, destPath); - } - - public static void skewBitmapFile(String fromPath, String destPath, float x, float y) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Matrix matrix = new Matrix(); - matrix.postSkew(x, y); - - int w = src.getWidth(); - int h = src.getHeight(); - - Bitmap bitmap = Bitmap.createBitmap(src, 0, 0, w, h, matrix, true); - saveBitmap(bitmap, destPath); - } - - public static void setBitmapFileColorFilter(String fromPath, String destPath, int color) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - Bitmap bitmap = Bitmap.createBitmap(src, 0, 0, - src.getWidth() - 1, src.getHeight() - 1); - Paint p = new Paint(); - ColorFilter filter = new LightingColorFilter(color, 1); - p.setColorFilter(filter); - Canvas canvas = new Canvas(bitmap); - canvas.drawBitmap(bitmap, 0, 0, p); - saveBitmap(bitmap, destPath); - } - - public static void setBitmapFileBrightness(String fromPath, String destPath, float brightness) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - ColorMatrix cm = new ColorMatrix(new float[] - { - 1, 0, 0, 0, brightness, - 0, 1, 0, 0, brightness, - 0, 0, 1, 0, brightness, - 0, 0, 0, 1, 0 - }); - - Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig()); - Canvas canvas = new Canvas(bitmap); - Paint paint = new Paint(); - paint.setColorFilter(new ColorMatrixColorFilter(cm)); - canvas.drawBitmap(src, 0, 0, paint); - saveBitmap(bitmap, destPath); - } - - public static void setBitmapFileContrast(String fromPath, String destPath, float contrast) { - if (!isExistFile(fromPath)) return; - Bitmap src = BitmapFactory.decodeFile(fromPath); - ColorMatrix cm = new ColorMatrix(new float[] - { - contrast, 0, 0, 0, 0, - 0, contrast, 0, 0, 0, - 0, 0, contrast, 0, 0, - 0, 0, 0, 1, 0 - }); - - Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(), src.getConfig()); - Canvas canvas = new Canvas(bitmap); - Paint paint = new Paint(); - paint.setColorFilter(new ColorMatrixColorFilter(cm)); - canvas.drawBitmap(src, 0, 0, paint); - - saveBitmap(bitmap, destPath); - } - - public static int getJpegRotate(String filePath) { - int rotate = 0; - try { - ExifInterface exif = new ExifInterface(filePath); - int iOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, -1); - - switch (iOrientation) { - case ExifInterface.ORIENTATION_ROTATE_90: - rotate = 90; - break; - case ExifInterface.ORIENTATION_ROTATE_180: - rotate = 180; - break; - case ExifInterface.ORIENTATION_ROTATE_270: - rotate = 270; - break; - default: - rotate = 0; - break; - } - } catch (IOException e) { - return 0; - } - - return rotate; - } - - public static File createNewPictureFile(Context context) { - SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd_HHmmss"); - String fileName = date.format(new Date()) + ".jpg"; - File file = new File(context.getExternalFilesDir(Environment.DIRECTORY_DCIM).getAbsolutePath() + File.separator + fileName); - return file; - } -} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/FilepickerActivity.java b/app/src/main/java/tw/music/streamer/FilepickerActivity.java deleted file mode 100644 index a7b7cc8..0000000 --- a/app/src/main/java/tw/music/streamer/FilepickerActivity.java +++ /dev/null @@ -1,266 +0,0 @@ -package tw.music.streamer; - -import android.Manifest; -import android.app.Activity; -import android.content.ClipData; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.graphics.Color; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.view.Window; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; - -import java.util.ArrayList; -import java.util.Random; - -public class FilepickerActivity extends AppCompatActivity { - - public final int REQ_CD_FP = 101; - - private Toolbar _toolbar; - - private ArrayList vd = new ArrayList<>(); - - private TextView textview1; - - private Intent intent = new Intent(); - private SharedPreferences data; - private Intent fp = new Intent(Intent.ACTION_GET_CONTENT); - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.filepicker); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE}, 1000); - } else { - initializeLogic(); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1000) { - initializeLogic(); - } - } - - private void initialize(Bundle _savedInstanceState) { - - _toolbar = findViewById(R.id._toolbar); - setSupportActionBar(_toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); - _toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _v) { - onBackPressed(); - } - }); - textview1 = findViewById(R.id.textview1); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - fp.setType("*/*"); - fp.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); - } - - private void initializeLogic() { - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - setTitle("zzfilepicker://"); - if (getIntent().getStringExtra("fileType").contains("/")) { - fp.setType(getIntent().getStringExtra("fileType")); - } else { - fp.setType("*/*"); - } - fp.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); - startActivityForResult(fp, REQ_CD_FP); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - case REQ_CD_FP: - if (_resultCode == Activity.RESULT_OK) { - ArrayList _filePath = new ArrayList<>(); - if (_data != null) { - if (_data.getClipData() != null) { - for (int _index = 0; _index < _data.getClipData().getItemCount(); _index++) { - ClipData.Item _item = _data.getClipData().getItemAt(_index); - _filePath.add(FileUtil.convertUriToFilePath(getApplicationContext(), _item.getUri())); - } - } else { - _filePath.add(FileUtil.convertUriToFilePath(getApplicationContext(), _data.getData())); - } - } - if (getIntent().getStringExtra("fileType").contains("/")) { - data.edit().putString("tmpPath", _filePath.get(0)).commit(); - finish(); - } else { - if (_filePath.get(0).endsWith(getIntent().getStringExtra("fileType"))) { - data.edit().putString("tmpPath", _filePath.get(0)).commit(); - finish(); - } else { - finish(); - } - } - } else { - finish(); - } - break; - default: - break; - } - } - - @Override - public void onBackPressed() { - /* -} - -private String queryName(Uri uri) { - java.io.File file = new java.io.File(uri.getPath()); - return file.getName(); -} - -@Override -protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch(_requestCode) { - case REQ_CD_FP: - if (_resultCode == Activity.RESULT_OK) { - if (_data != null) { - textview1.setText(queryName(_data.getData())); - } - } - else { - finish(); - } - break; - default: - break; - } -} - -@Override -public void onBackPressed() { -*/ - finish(); - } - - @Override - public void onStart() { - super.onStart(); - _DarkMode(); - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - private void _DarkMode() { - int nightModeFlags = getResources().getConfiguration().uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK; - if (nightModeFlags == android.content.res.Configuration.UI_MODE_NIGHT_YES) { - textview1.setBackgroundColor(0xFF252525); - textview1.setTextColor(0xFFFFFFFF); - _customNav("#252525"); - } else { - textview1.setBackgroundColor(0xFFFFFFFF); - textview1.setTextColor(0xFF000000); - _customNav("#FFFFFF"); - } - } - - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - -} diff --git a/app/src/main/java/tw/music/streamer/LandingActivity.java b/app/src/main/java/tw/music/streamer/LandingActivity.java new file mode 100644 index 0000000..656d0b1 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/LandingActivity.java @@ -0,0 +1,100 @@ +package tw.music.streamer; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.net.Uri; +import android.graphics.Color; +import android.graphics.Typeface; +import android.graphics.drawable.GradientDrawable; +import android.widget.LinearLayout; +import android.view.View; + +import androidx.appcompat.app.AppCompatActivity; + +import com.google.android.material.button.MaterialButton; + +public class LandingActivity extends AppCompatActivity { + + private MaterialButton btn_login, btn_register, btn_discord; + private LinearLayout land_base; + private Uri zz_discord; + + @Override + protected void onCreate(Bundle a) { + super.onCreate(a); + setContentView(R.layout.landing); + zz_discord = Uri.parse(getIntent().getStringExtra("discord-server")); + initVariables(getApplicationContext()); + initOnClick(getApplicationContext()); + initLogic(getApplicationContext()); + } + + private void initVariables(final Context a) { + btn_login = findViewById(R.id.btn_login); + btn_register = findViewById(R.id.btn_register); + btn_discord = findViewById(R.id.btn_discord); + land_base = findViewById(R.id.land_base); + } + + private void initOnClick(final Context a) { + btn_login.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View b) { + Intent i = new Intent(getApplicationContext(), LoginActivity.class); + startActivity(i); + finish(); + } + }); + btn_register.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View b) { + Intent i = new Intent(getApplicationContext(), RegisterActivity.class); + startActivity(i); + finish(); + } + }); + btn_discord.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View b) { + Intent i = new Intent(Intent.ACTION_VIEW); + i.setData(zz_discord); + startActivity(i); + } + }); + } + + private void initLogic(final Context a) { + roundTopCorner(land_base, dip(12)); + roundCorner(btn_login, dip(20), Color.parseColor("#fcc2ff")); + roundCornerWithOutline(btn_register, dip(20), Color.WHITE, Color.parseColor("#c9d0ff")); + roundCorner(btn_discord, dip(15), Color.parseColor("#3b396e")); + } + + private void roundCorner(View a, float b, int c) { + GradientDrawable d = new GradientDrawable(); + d.setColor(c); + d.setCornerRadius(b); + a.setBackground(d); + } + + private void roundCornerWithOutline(View a, float b, int c, int d) { + GradientDrawable e = new GradientDrawable(); + e.setColor(c); + e.setCornerRadius(b); + e.setStroke(dip(2), d); + a.setBackground(e); + } + + private void roundTopCorner(View a, float b) { + GradientDrawable c = new GradientDrawable(); + c.setColor(Color.WHITE); + c.setCornerRadii(new float[]{b, b, b, b, 0f, 0f, 0f, 0f}); + a.setBackground(c); + } + + private int dip(int a) { + return (int) (a * getApplicationContext().getResources().getDisplayMetrics().density); + } + +} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/LogcatActivity.java b/app/src/main/java/tw/music/streamer/LogcatActivity.java deleted file mode 100644 index ed46abb..0000000 --- a/app/src/main/java/tw/music/streamer/LogcatActivity.java +++ /dev/null @@ -1,281 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -public class LogcatActivity extends AppCompatActivity { - - - private FloatingActionButton _fab; - private HashMap var_map = new HashMap<>(); - - private ArrayList> theme_map = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private ImageView imageview1; - private TextView textview2; - private ScrollView vscroll1; - private TextView textview1; - - private SharedPreferences data; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.logcat); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - _fab = findViewById(R.id._fab); - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - imageview1 = findViewById(R.id.imageview1); - textview2 = findViewById(R.id.textview2); - vscroll1 = findViewById(R.id.vscroll1); - textview1 = findViewById(R.id.textview1); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - _fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - data.edit().remove("errorLog").commit(); - textview1.setText("Seems empty here..."); - _customSnack("Cleared!", 1); - } - }); - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - textview1.setTextIsSelectable(true); - _loadTheme(); - if (data.getString("errorLog", "").equals("")) { - textview1.setText("Seems empty here..."); - } else { - textview1.setText(data.getString("errorLog", "")); - } - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview1); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - _fab.setBackgroundTintList(android.content.res.ColorStateList.valueOf(Color.parseColor(theme_map.get(0).get("colorButton").toString()))); - _fab.setRippleColor(Color.parseColor(theme_map.get(0).get("colorRipple").toString())); - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _fab.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString())); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - -} diff --git a/app/src/main/java/tw/music/streamer/LoginActivity.java b/app/src/main/java/tw/music/streamer/LoginActivity.java new file mode 100644 index 0000000..d40b688 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/LoginActivity.java @@ -0,0 +1,80 @@ +package tw.music.streamer; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.text.TextUtils; +import android.content.Intent; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.google.android.material.button.MaterialButton; +import com.google.android.material.textfield.TextInputEditText; + +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; + +public class LoginActivity extends AppCompatActivity { + + private TextInputEditText zzEmail, zzPassword; + private MaterialButton btnLogin; + private FirebaseAuth auth; + + @Override + protected void onCreate(Bundle a) { + super.onCreate(a); + setContentView(R.layout.login); + initVariables(getApplicationContext()); + initOnClick(getApplicationContext()); + initFirebase(getApplicationContext()); + initLogic(getApplicationContext()); + } + + private void initVariables(final Context a) { + zzEmail = findViewById(R.id.etEmail); + zzPassword = findViewById(R.id.etPassword); + btnLogin = findViewById(R.id.btnLogin); + } + + private void initFirebase(final Context a) { + auth = FirebaseAuth.getInstance(); + } + + private void initOnClick(final Context a) { + btnLogin.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + loginUser(); + } + }); + } + + private void initLogic(final Context a) { + } + + private void loginUser() { + String email = zzEmail.getText().toString().trim(); + String password = zzPassword.getText().toString().trim(); + if (TextUtils.isEmpty(email)) { + zzEmail.setError("Email is required."); + return; + } + if (TextUtils.isEmpty(password)) { + zzPassword.setError("Password is required."); + return; + } + auth.signInWithEmailAndPassword(email, password).addOnCompleteListener(LoginActivity.this, task -> { + if (task.isSuccessful()) { + FirebaseUser user = auth.getCurrentUser(); + Intent intent = new Intent(getApplicationContext(), MainActivity.class); + startActivity(intent); + finish(); + } else { + Toast.makeText(getApplicationContext(), "Login failed: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show(); + } + }); + } + +} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/LyricsActivity.java b/app/src/main/java/tw/music/streamer/LyricsActivity.java deleted file mode 100644 index e992ccf..0000000 --- a/app/src/main/java/tw/music/streamer/LyricsActivity.java +++ /dev/null @@ -1,724 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.text.InputType; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.BaseAdapter; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Random; - -public class LyricsActivity extends AppCompatActivity { - - - private String musicName = ""; - private boolean isShown = false; - - private ArrayList> theme_map = new ArrayList<>(); - private ArrayList> lyricsListmap = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private ImageView imageview1; - private TextView textview1; - private ImageView imageview2; - private TextView textview2; - private ListView listview1; - private TextView textview3; - - private RequestNetwork rn; - private RequestNetwork.RequestListener _rn_request_listener; - private SharedPreferences data; - private Intent intent = new Intent(); - private AlertDialog.Builder dialog; - private org.json.JSONArray _resultArray; - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.lyrics); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - imageview1 = findViewById(R.id.imageview1); - textview1 = findViewById(R.id.textview1); - imageview2 = findViewById(R.id.imageview2); - textview2 = findViewById(R.id.textview2); - listview1 = findViewById(R.id.listview1); - textview3 = findViewById(R.id.textview3); - rn = new RequestNetwork(this); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - dialog = new AlertDialog.Builder(this); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - onBackPressed(); - } - }); - - imageview2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - isShown = false; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - rn.startRequestNetwork(RequestNetworkController.GET, "https://api.happi.dev/v1/music?q=".concat(musicName.concat("&apikey=".concat(data.getString("apiKey", "")))), "A", _rn_request_listener); - textview3.setText("Searching..."); - } - }); - - textview2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - LinearLayout mylayout = new LinearLayout(LyricsActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(LyricsActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - myedittext.setText(musicName); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Music name"); - dialog.setTitle("Search music lyrics"); - dialog.setPositiveButton("Search", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - if (myedittext.getText().toString().trim().equals("")) { - _customSnack("Fill those blanks!", 2); - } else { - musicName = myedittext.getText().toString().trim(); - isShown = false; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - rn.startRequestNetwork(RequestNetworkController.GET, "https://api.happi.dev/v1/music?q=".concat(musicName.concat("&apikey=".concat(data.getString("apiKey", "")))), "A", _rn_request_listener); - textview3.setText("Searching..."); - } - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - } - }); - dialog.create().show(); - } - }); - - _rn_request_listener = new RequestNetwork.RequestListener() { - @Override - public void onResponse(String _param1, String _param2) { - final String _tag = _param1; - final String _response = _param2; - if (_tag.equals("A")) { - try { - org.json.JSONObject _json = new org.json.JSONObject(_response); - if (_json.getBoolean("success")) { - if (_json.getInt("length") > 0) { - lyricsListmap.clear(); - _resultArray = _json.getJSONArray("result"); - double _tmpDouble = 0; - isShown = false; - textview3.setVisibility(View.GONE); - listview1.setVisibility(View.VISIBLE); - for (int _repeat21 = 0; _repeat21 < _json.getInt("length"); _repeat21++) { - org.json.JSONObject _resultObject = _resultArray.getJSONObject((int) _tmpDouble); - { - HashMap _item = new HashMap<>(); - _item.put("track", _resultObject.getString("track")); - lyricsListmap.add(_item); - } - - lyricsListmap.get(lyricsListmap.size() - 1).put("artist", _resultObject.getString("artist")); - lyricsListmap.get(lyricsListmap.size() - 1).put("album", _resultObject.getString("album")); - ((BaseAdapter) listview1.getAdapter()).notifyDataSetChanged(); - _tmpDouble++; - } - } else { - lyricsListmap.clear(); - ((BaseAdapter) listview1.getAdapter()).notifyDataSetChanged(); - isShown = false; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - textview3.setText("Lyrics not found or wrong music name"); - } - } else { - isShown = false; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - textview3.setText("Not success to retrieve lyrics! (Wrong API Key?)"); - } - } catch (Exception _e) { - textview1.setText(_e.toString()); - } - } else { - if (_tag.equals("B")) { - try { - org.json.JSONObject _json = new org.json.JSONObject(_response); - if (_json.getBoolean("success")) { - org.json.JSONObject _result = _json.getJSONObject("result"); - isShown = true; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - textview3.setText(_result.getString("lyrics")); - } else { - isShown = false; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - textview3.setText("Not success to retrieve lyrics! (Wrong API key?)"); - } - } catch (Exception _e) { - textview1.setText(_e.toString()); - } - } - } - } - - @Override - public void onErrorResponse(String _param1, String _param2) { - final String _tag = _param1; - final String _message = _param2; - isShown = false; - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.VISIBLE); - textview3.setText("Failed to retrieve lyrics (Internet connection? Or invalid API key?)"); - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - textview3.setTextIsSelectable(true); - _loadTheme(); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - listview1.setAdapter(new Listview1Adapter(lyricsListmap)); - musicName = getIntent().getStringExtra("musicName"); - if (data.getString("apiKey", "").equals("")) { - SketchwareUtil.showMessage(getApplicationContext(), "Setup the api key first!"); - intent.setClass(getApplicationContext(), SettingsActivity.class); - startActivity(intent); - finish(); - } else { - listview1.setVisibility(View.GONE); - rn.startRequestNetwork(RequestNetworkController.GET, "https://api.happi.dev/v1/music?q=".concat(musicName.concat("&apikey=".concat(data.getString("apiKey", "")))), "A", _rn_request_listener); - textview3.setText("Searching..."); - } - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onBackPressed() { - if (isShown) { - isShown = false; - textview3.setVisibility(View.GONE); - listview1.setVisibility(View.VISIBLE); - } else { - finish(); - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - - private void _rippleEffect(final View _view, final String _color) { - _view.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(_color))); - _view.setClickable(true); - } - - public void drawableclass() { - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview1); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview2); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview3.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview2.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - private void _retrieveLyrics(final double _position) { - listview1.setVisibility(View.GONE); - textview3.setVisibility(View.GONE); - textview3.setText("Please Wait..."); - try { - org.json.JSONObject _resultObject = _resultArray.getJSONObject((int) _position); - rn.startRequestNetwork(RequestNetworkController.GET, _resultObject.getString("api_lyrics").concat("?apikey=06349bEfBAJKGBdckYz1qtj5acwL8x9VxFFUIBULWxW0HerKCRAEZgG9"), "B", _rn_request_listener); - } catch (Exception _e) { - isShown = false; - textview3.setText("Error while parsing json. (Wrong API key?)"); - } - } - - private void _abandonFocus() { - View _tmpView = this.getCurrentFocus(); - if (_tmpView != null) { - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(_tmpView.getWindowToken(), 0); - } - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public class Listview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Listview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.lyricslist, null); - } - - final LinearLayout linear1 = _v.findViewById(R.id.linear1); - final TextView textview1 = _v.findViewById(R.id.textview1); - final TextView textview2 = _v.findViewById(R.id.textview2); - - textview1.setText(_data.get(_position).get("track").toString()); - textview2.setText(_data.get(_position).get("artist").toString().concat(" - ".concat(_data.get(_position).get("album").toString()))); - _rippleEffect(linear1, theme_map.get(0).get("colorRipple").toString()); - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - linear1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _retrieveLyrics(_position); - } - }); - - return _v; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/MainActivity.java b/app/src/main/java/tw/music/streamer/MainActivity.java index 5f6b21c..b1b4adb 100644 --- a/app/src/main/java/tw/music/streamer/MainActivity.java +++ b/app/src/main/java/tw/music/streamer/MainActivity.java @@ -1,957 +1,133 @@ package tw.music.streamer; -import android.animation.Animator; -import android.animation.ObjectAnimator; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; +import android.Manifest; +import android.content.Context; import android.content.Intent; -import android.content.SharedPreferences; import android.content.pm.PackageManager; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.net.Uri; import android.os.Build; +import android.os.Handler; import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.animation.DecelerateInterpolator; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import androidx.core.content.ContextCompat; -import com.bumptech.glide.Glide; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; +import com.google.android.material.textview.MaterialTextView; + import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.database.ValueEventListener; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; public class MainActivity extends AppCompatActivity { - private Timer _timer = new Timer(); - - private HashMap map = new HashMap<>(); - private boolean isBanned = false; - private double banNum = 0; - private HashMap tmpMapVar = new HashMap<>(); - - private ArrayList> profile_map = new ArrayList<>(); - private ArrayList> theme_map = new ArrayList<>(); - private ArrayList> tmpMap = new ArrayList<>(); - private ArrayList> bansMap = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private LinearLayout linear6; - private LinearLayout linear7; - private LinearLayout lineartm; - private LinearLayout linear4; - private ImageView imageview1; - private TextView textview11; - private TextView textview5; - private LinearLayout linear5; - private Button button1; - private LinearLayout linear3; - private ImageView image_user; - private EditText einput_name; - private TextView textview7; - private TextView textview8; - private TextView textview9; - private TextView textview10; - private TextView textview1; - private TextView textview2; - private TextView textview6; - private TextView textview3; - private ImageView imageview2; - private TextView textview4; - - private SharedPreferences data; - private DatabaseReference update_db; - private ChildEventListener _update_db_child_listener; - private Intent intent = new Intent(); - private AlertDialog.Builder d; - private DatabaseReference profile; - private ChildEventListener _profile_child_listener; - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private Intent activityChanger = new Intent(); - private DatabaseReference prof_img; - private ChildEventListener _prof_img_child_listener; - private TimerTask timer; - private ObjectAnimator objectanim3 = new ObjectAnimator(); - private RequestNetwork internetchecker; - private RequestNetwork.RequestListener _internetchecker_request_listener; - private TimerTask delaynointernet; - private DatabaseReference prof_bans; - private ChildEventListener _prof_bans_child_listener; - private RequestNetwork rn; - private RequestNetwork.RequestListener _rn_request_listener; - private android.content.pm.PackageInfo packageInfo; - private boolean _isNoInternet = false; + private FirebaseAuth auth; + private MaterialTextView welcome_text; + private LinearLayout screen; + private boolean nr; @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); + protected void onCreate(Bundle a) { + super.onCreate(a); setContentView(R.layout.main); - update_db = FirebaseDatabase.getInstance().getReference("update/version"); - profile = FirebaseDatabase.getInstance().getReference("profile/text"); - prof_img = FirebaseDatabase.getInstance().getReference("profile/image"); - prof_bans = FirebaseDatabase.getInstance().getReference("profile/bans"); - initialize(_savedInstanceState); - initializeLogic(); + initVariables(getApplicationContext()); + initFirebase(getApplicationContext()); + initOnClick(getApplicationContext()); + initLogic(getApplicationContext()); } - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - linear6 = findViewById(R.id.linear6); - linear7 = findViewById(R.id.linear7); - lineartm = findViewById(R.id.lineartm); - linear4 = findViewById(R.id.linear4); - imageview1 = findViewById(R.id.imageview1); - textview11 = findViewById(R.id.textview11); - textview5 = findViewById(R.id.textview5); - linear5 = findViewById(R.id.linear5); - button1 = findViewById(R.id.button1); - linear3 = findViewById(R.id.linear3); - image_user = findViewById(R.id.image_user); - einput_name = findViewById(R.id.einput_name); - textview7 = findViewById(R.id.textview7); - textview8 = findViewById(R.id.textview8); - textview9 = findViewById(R.id.textview9); - textview10 = findViewById(R.id.textview10); - textview1 = findViewById(R.id.textview1); - textview2 = findViewById(R.id.textview2); - textview6 = findViewById(R.id.textview6); - textview3 = findViewById(R.id.textview3); - imageview2 = findViewById(R.id.imageview2); - textview4 = findViewById(R.id.textview4); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - d = new AlertDialog.Builder(this); - Auth = FirebaseAuth.getInstance(); - internetchecker = new RequestNetwork(this); - rn = new RequestNetwork(this); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setData(Uri.parse("https://zrytezene.xyz")); - intent.setAction(Intent.ACTION_VIEW); - startActivity(intent); - } - }); + private void initVariables(final Context a) { + welcome_text = findViewById(R.id.wlctext); + screen = findViewById(R.id.base); + nr = false; + } - button1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (einput_name.getText().toString().trim().equals("") || (einput_name.getText().toString().trim().length() > 30)) { - _customSnack("Username field can't be empty or more than 30 characters! ", 2); - } else { - map = new HashMap<>(); - map.put("profile", FirebaseAuth.getInstance().getCurrentUser().getEmail()); - map.put("username", einput_name.getText().toString().trim()); - map.put("bio", "Hi, i'm using ZryteZene now!"); - profile.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).updateChildren(map); - activityChanger.setClass(getApplicationContext(), MainActivity.class); - startActivity(activityChanger); - finish(); - } - } - }); + private void initFirebase(final Context a) { + auth = FirebaseAuth.getInstance(); + } - image_user.setOnClickListener(new View.OnClickListener() { + private void initOnClick(final Context a) { + screen.setOnClickListener(new View.OnClickListener() { @Override - public void onClick(View _view) { - activityChanger.setClass(getApplicationContext(), FilepickerActivity.class); - activityChanger.putExtra("fileType", "image/*"); - startActivity(activityChanger); + public void onClick(View b) { + retry(); } }); + } - textview3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _randomEmoteUwU(); - } - }); + private void initLogic(final Context a) { + getVersion(a); + } - imageview2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _randomEmoteUwU(); + private void getVersion(final Context a) { + FirebaseDatabase.getInstance().getReference("zrytezene/version").get() + .addOnFailureListener(e -> { + nr = true; + welcome_text.setText("Failed to connect to ZryteZene, tap on the screen to retry"); + e.printStackTrace(); + }).addOnCompleteListener(b -> { + if (b.isSuccessful()) { + onVersionRetrieved(b.getResult()); + } else { + nr = true; + welcome_text.setText("Failed to connect to ZryteZene, tap on the screen to retry"); } }); + } - _update_db_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if ((Double.parseDouble(_childValue.get("version").toString()) > (double) packageInfo.versionCode) || _childValue.get("closed").toString().equals("1")) { - update_db.removeEventListener(_update_db_child_listener); - profile.removeEventListener(_profile_child_listener); - prof_img.removeEventListener(_prof_img_child_listener); - prof_bans.removeEventListener(_prof_bans_child_listener); - activityChanger.setClass(getApplicationContext(), UpdateappActivity.class); - activityChanger.putExtra("updateData", new Gson().toJson(_childValue)); - startActivity(activityChanger); - finish(); - } else { - tmpMapVar = new HashMap<>(_childValue); - prof_img.addChildEventListener(_prof_img_child_listener); - if (_checkPermission() && (data.getString("setup", "").equals("1") && ((FirebaseAuth.getInstance().getCurrentUser() != null) && data.getString("license", "").equals("1")))) { - if (Auth.getCurrentUser().isEmailVerified()) { - profile.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - profile_map = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - profile_map.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - if (profile_map.size() > 0) { - double _tmpNum = 0; - boolean _endTask = false; - for (int _repeat35 = 0; _repeat35 < profile_map.size(); _repeat35++) { - if (profile_map.get((int) _tmpNum).get("profile").toString().equals(FirebaseAuth.getInstance().getCurrentUser().getEmail())) { - _endTask = true; - if (!profile_map.get((int) _tmpNum).containsKey("bio")) { - map = new HashMap<>(); - map = profile_map.get((int) _tmpNum); - map.put("bio", "Hi, i'm using ZryteZene now!"); - profile.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).updateChildren(map); - } - prof_bans.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - bansMap = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - bansMap.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - if (bansMap.size() > 0) { - prof_bans.addChildEventListener(_prof_bans_child_listener); - } else { - _chkChglog(); - } - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } else { - if ((_tmpNum == (profile_map.size() - 1)) && !_endTask) { - linear1.setVisibility(View.GONE); - linear2.setVisibility(View.VISIBLE); - lineartm.setVisibility(View.INVISIBLE); - } - } - _tmpNum++; - } - } else { - linear1.setVisibility(View.GONE); - linear2.setVisibility(View.VISIBLE); - lineartm.setVisibility(View.INVISIBLE); - } - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } else { - FirebaseAuth.getInstance().signOut(); - SketchwareUtil.showMessage(getApplicationContext(), "Your account isn't verified! Please relogin."); - update_db.removeEventListener(_update_db_child_listener); - profile.removeEventListener(_profile_child_listener); - prof_img.removeEventListener(_prof_img_child_listener); - prof_bans.removeEventListener(_prof_bans_child_listener); - activityChanger.setClass(getApplicationContext(), WizardActivity.class); - startActivity(activityChanger); - finish(); - } + private void onVersionRetrieved(DataSnapshot a) { + if (a.exists()) { + welcome_text.setText(a.child("chadwords").getValue(String.class)); + if (checkVersion(a)) { + if (checkAccount()) { + if (checkPermissions()) { + openActivity(StreamingActivity.class); } else { - update_db.removeEventListener(_update_db_child_listener); - profile.removeEventListener(_profile_child_listener); - prof_img.removeEventListener(_prof_img_child_listener); - prof_bans.removeEventListener(_prof_bans_child_listener); - activityChanger.setClass(getApplicationContext(), WizardActivity.class); - startActivity(activityChanger); - finish(); + openActivity(PermissionsActivity.class); } - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - update_db.addChildEventListener(_update_db_child_listener); - - _profile_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile.addChildEventListener(_profile_child_listener); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if ((FirebaseAuth.getInstance().getCurrentUser() != null)) { - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - image_user.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(image_user) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - image_user.setImageDrawable(circularBitmapDrawable); - } - }); - } - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if ((FirebaseAuth.getInstance().getCurrentUser() != null)) { - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(image_user) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - image_user.setImageDrawable(circularBitmapDrawable); - } - }); - } - } - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - - _internetchecker_request_listener = new RequestNetwork.RequestListener() { - @Override - public void onResponse(String _param1, String _param2) { - final String _tag = _param1; - final String _response = _param2; - if (_isNoInternet) { - _isNoInternet = false; - textview4.setText("Thx!"); - delaynointernet = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - internetchecker.startRequestNetwork(RequestNetworkController.GET, "https://www.google.com", "A", _internetchecker_request_listener); - } - }); - } - }; - _timer.schedule(delaynointernet, 1500); } else { - internetchecker.startRequestNetwork(RequestNetworkController.GET, "https://www.google.com", "A", _internetchecker_request_listener); - } - } - - @Override - public void onErrorResponse(String _param1, String _param2) { - final String _tag = _param1; - final String _message = _param2; - if (_isNoInternet) { - internetchecker.startRequestNetwork(RequestNetworkController.GET, "https://www.google.com", "A", _internetchecker_request_listener); - } else { - _isNoInternet = true; - textview4.setText("Please enable your internet!"); - _randomEmoteUwU(); - internetchecker.startRequestNetwork(RequestNetworkController.GET, "https://www.google.com", "A", _internetchecker_request_listener); - } - } - }; - - _prof_bans_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (FirebaseAuth.getInstance().getCurrentUser().getUid().equals(_childKey)) { - isBanned = true; - textview9.setText("Reason : ".concat(_childValue.get("reason").toString())); - linear1.setVisibility(View.GONE); - linear6.setVisibility(View.VISIBLE); - lineartm.setVisibility(View.GONE); - } else { - if ((banNum == (bansMap.size() - 1)) && !isBanned) { - _chkChglog(); - } - } - banNum++; - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_bans.addChildEventListener(_prof_bans_child_listener); - - _rn_request_listener = new RequestNetwork.RequestListener() { - @Override - public void onResponse(String _param1, String _param2) { - final String _tag = _param1; - final String _response = _param2; - - } - - @Override - public void onErrorResponse(String _param1, String _param2) { - final String _tag = _param1; - final String _message = _param2; - - } - }; - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - try { - packageInfo = MainActivity.this.getPackageManager().getPackageInfo(getPackageName(), 0); - textview6.setText(" " + packageInfo.versionName); - } catch (Exception _e) { - } - einput_name.getBackground().setColorFilter(Color.parseColor("#2196F3"), PorterDuff.Mode.SRC_ATOP); - update_db.removeEventListener(_update_db_child_listener); - prof_img.removeEventListener(_prof_img_child_listener); - prof_bans.removeEventListener(_prof_bans_child_listener); - linear2.setVisibility(View.GONE); - linear6.setVisibility(View.GONE); - linear7.setVisibility(View.GONE); - textview11.setVisibility(View.GONE); - image_user.setColorFilter(0xFF2196F3, PorterDuff.Mode.MULTIPLY); - Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"); - textview1.setTypeface(tf, 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textview4.setTypeface(tf, 0); - textview5.setTypeface(tf, 0); - textview6.setTypeface(tf, 0); - textview7.setTypeface(tf, 0); - textview8.setTypeface(tf, 0); - textview9.setTypeface(tf, 0); - textview10.setTypeface(tf, 0); - textview11.setTypeface(tf, 0); - einput_name.setTypeface(tf, 0); - button1.setTypeface(tf, 0); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), "#2196F3", "#FFFFFF", 0, button1); - lineartm.setTranslationY(SketchwareUtil.getDip(getApplicationContext(), -75)); - if (data.getString("fvsAsc", "").equals("")) { - data.edit().putString("fvsAsc", "0").commit(); - } - if (data.getString("nightcore", "").equals("") || Build.VERSION.SDK_INT < Build.VERSION_CODES.M) { - data.edit().putString("nightcore", "0").commit(); - } - if (data.getString("griddata", "").equals("")) { - { - HashMap _item = new HashMap<>(); - _item.put("themesname", "$default_1$"); - theme_map.add(_item); - } - - theme_map.get(0).put("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#1769AA\",\"colorBackgroundText\":\"#000000\",\"colorBackground\":\"#FFFFFF\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#A8A8A8\",\"colorRipple\":\"#40000000\",\"colorPrimaryCardImage\":\"#000000\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#000000\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#FFFFFF\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#000000\",\"colorPrimaryCard\":\"#FFFFFF\",\"colorBackgroundCardImage\":\"#000000\"}]"); - theme_map.get(0).put("themesinfo", "The default style of TeamMusic"); - theme_map.get(0).put("themesauthor", "TeamWorks DEV"); - theme_map.get(0).put("os-thm-version", "2"); - { - HashMap _item = new HashMap<>(); - _item.put("themesname", "$default_2$"); - theme_map.add(_item); - } - - theme_map.get(1).put("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#252525\",\"colorBackgroundText\":\"#FFFFFF\",\"colorBackground\":\"#252525\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#808080\",\"colorRipple\":\"#40FFFFFF\",\"colorPrimaryCardImage\":\"#98A0A8\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#98A0A8\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#404040\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#98A0A8\",\"colorPrimaryCard\":\"#404040\",\"colorBackgroundCardImage\":\"#98A0A8\"}]"); - theme_map.get(1).put("themesinfo", "A Material dark theme for TeamMusic."); - theme_map.get(1).put("themesauthor", "Axhyre"); - theme_map.get(1).put("os-thm-version", "2"); - data.edit().putString("griddata", new Gson().toJson(theme_map)).commit(); - } else { - theme_map = new Gson().fromJson(data.getString("griddata", ""), new TypeToken>>() { - }.getType()); - tmpMapVar = new HashMap<>(); - tmpMapVar = theme_map.get(0); - if (!new Gson().toJson(tmpMapVar).equals("{\"themesjson\":\"[{\\\"colorPrimary\\\":\\\"#2196F3\\\",\\\"colorPrimaryDark\\\":\\\"#1769AA\\\",\\\"colorBackgroundText\\\":\\\"#000000\\\",\\\"colorBackground\\\":\\\"#FFFFFF\\\",\\\"colorButton\\\":\\\"#F50057\\\",\\\"shadow\\\":\\\"1\\\",\\\"colorHint\\\":\\\"#A8A8A8\\\",\\\"colorRipple\\\":\\\"#40000000\\\",\\\"colorPrimaryCardImage\\\":\\\"#000000\\\",\\\"version\\\":\\\"2\\\",\\\"colorPrimaryText\\\":\\\"#FFFFFF\\\",\\\"colorPrimaryImage\\\":\\\"#FFFFFF\\\",\\\"colorBackgroundImage\\\":\\\"#2196F3\\\",\\\"colorBackgroundCardText\\\":\\\"#000000\\\",\\\"statusbarIcon\\\":\\\"1\\\",\\\"colorBackgroundCard\\\":\\\"#FFFFFF\\\",\\\"colorButtonText\\\":\\\"#FFFFFF\\\",\\\"colorPrimaryCardText\\\":\\\"#000000\\\",\\\"colorPrimaryCard\\\":\\\"#FFFFFF\\\",\\\"colorBackgroundCardImage\\\":\\\"#000000\\\"}]\",\"themesauthor\":\"TeamWorks DEV\",\"themesname\":\"$default_1$\",\"themesinfo\":\"The default style of TeamMusic\",\"os-thm-version\":\"2\"}")) { - theme_map.get(0).put("themesname", "$default_1$"); - theme_map.get(0).put("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#1769AA\",\"colorBackgroundText\":\"#000000\",\"colorBackground\":\"#FFFFFF\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#A8A8A8\",\"colorRipple\":\"#40000000\",\"colorPrimaryCardImage\":\"#000000\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#000000\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#FFFFFF\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#000000\",\"colorPrimaryCard\":\"#FFFFFF\",\"colorBackgroundCardImage\":\"#000000\"}]"); - theme_map.get(0).put("themesinfo", "The default style of TeamMusic"); - theme_map.get(0).put("themesauthor", "TeamWorks DEV"); - theme_map.get(0).put("os-thm-version", "2"); - data.edit().putString("griddata", new Gson().toJson(theme_map)).commit(); - } - if (theme_map.size() > 1) { - tmpMapVar = theme_map.get(1); - if (!new Gson().toJson(tmpMapVar).equals("{\"themesjson\":\"[{\\\"colorPrimary\\\":\\\"#2196F3\\\",\\\"colorPrimaryDark\\\":\\\"#252525\\\",\\\"colorBackgroundText\\\":\\\"#FFFFFF\\\",\\\"colorBackground\\\":\\\"#252525\\\",\\\"colorButton\\\":\\\"#F50057\\\",\\\"shadow\\\":\\\"1\\\",\\\"colorHint\\\":\\\"#808080\\\",\\\"colorRipple\\\":\\\"#40FFFFFF\\\",\\\"colorPrimaryCardImage\\\":\\\"#98A0A8\\\",\\\"version\\\":\\\"2\\\",\\\"colorPrimaryText\\\":\\\"#FFFFFF\\\",\\\"colorPrimaryImage\\\":\\\"#FFFFFF\\\",\\\"colorBackgroundImage\\\":\\\"#2196F3\\\",\\\"colorBackgroundCardText\\\":\\\"#98A0A8\\\",\\\"statusbarIcon\\\":\\\"1\\\",\\\"colorBackgroundCard\\\":\\\"#404040\\\",\\\"colorButtonText\\\":\\\"#FFFFFF\\\",\\\"colorPrimaryCardText\\\":\\\"#98A0A8\\\",\\\"colorPrimaryCard\\\":\\\"#404040\\\",\\\"colorBackgroundCardImage\\\":\\\"#98A0A8\\\"}]\",\"themesauthor\":\"Axhyre\",\"themesname\":\"$default_2$\",\"themesinfo\":\"A Material dark theme for TeamMusic.\",\"os-thm-version\":\"2\"}")) { - { - HashMap _item = new HashMap<>(); - _item.put("themesname", "$default_2$"); - theme_map.add(1, _item); - } - - theme_map.get(1).put("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#252525\",\"colorBackgroundText\":\"#FFFFFF\",\"colorBackground\":\"#252525\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#808080\",\"colorRipple\":\"#40FFFFFF\",\"colorPrimaryCardImage\":\"#98A0A8\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#98A0A8\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#404040\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#98A0A8\",\"colorPrimaryCard\":\"#404040\",\"colorBackgroundCardImage\":\"#98A0A8\"}]"); - theme_map.get(1).put("themesinfo", "A Material dark theme for TeamMusic."); - theme_map.get(1).put("themesauthor", "Axhyre"); - theme_map.get(1).put("os-thm-version", "2"); - data.edit().putString("griddata", new Gson().toJson(theme_map)).commit(); + openActivity(LandingActivity.class, a.child("discord-server").getValue(String.class)); } } else { - { - HashMap _item = new HashMap<>(); - _item.put("themesname", "$default_2$"); - theme_map.add(_item); - } - - theme_map.get(1).put("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#252525\",\"colorBackgroundText\":\"#FFFFFF\",\"colorBackground\":\"#252525\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#808080\",\"colorRipple\":\"#40FFFFFF\",\"colorPrimaryCardImage\":\"#98A0A8\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#98A0A8\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#404040\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#98A0A8\",\"colorPrimaryCard\":\"#404040\",\"colorBackgroundCardImage\":\"#98A0A8\"}]"); - theme_map.get(1).put("themesinfo", "A Material dark theme for TeamMusic."); - theme_map.get(1).put("themesauthor", "Axhyre"); - theme_map.get(1).put("os-thm-version", "2"); - data.edit().putString("griddata", new Gson().toJson(theme_map)).commit(); + openActivity(UpdateAppActivity.class); } - } - if (data.getString("playlist", "").equals("")) { - data.edit().putString("playlist", "[]").commit(); - } - if (data.getString("errorCountdown", "").equals("")) { - data.edit().putString("errorCountdown", "30").commit(); - } - if (data.getString("nightcoreSpeed", "").equals("")) { - data.edit().putString("nightcoreSpeed", "2").commit(); - } - if (data.getString("showPreview", "").equals("")) { - data.edit().putString("showPreview", "1").commit(); - } - if (!data.getString("lastPath", "").equals("")) { - data.edit().remove("lastPath").commit(); - } - if (data.getString("playerUI", "").equals("")) { - data.edit().putString("playerUI", "0").commit(); - } - if (data.getString("fpuMode", "").equals("")) { - data.edit().putString("fpuMode", "0").commit(); - } - if (data.getString("showVisualizer", "").equals("")) { - data.edit().putString("showVisualizer", "1").commit(); - } - if (data.getString("colorTransparency", "").equals("")) { - data.edit().putString("colorTransparency", "100").commit(); - } - if (!data.getString("themesactive", "").equals("")) { - data.edit().remove("themesactive").commit(); - } - if (data.getString("themesjson", "").equals("")) { - data.edit().putString("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#1769AA\",\"colorBackgroundText\":\"#000000\",\"colorBackground\":\"#FFFFFF\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#A8A8A8\",\"colorRipple\":\"#40000000\",\"colorPrimaryCardImage\":\"#000000\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#000000\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#FFFFFF\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#000000\",\"colorPrimaryCard\":\"#FFFFFF\",\"colorBackgroundCardImage\":\"#000000\"}]").commit(); } else { - tmpMap = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - if (tmpMap.get(0).containsKey("version")) { - if (!tmpMap.get(0).get("version").toString().equals("2")) { - data.edit().putString("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#1769AA\",\"colorBackgroundText\":\"#000000\",\"colorBackground\":\"#FFFFFF\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#A8A8A8\",\"colorRipple\":\"#40000000\",\"colorPrimaryCardImage\":\"#000000\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#000000\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#FFFFFF\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#000000\",\"colorPrimaryCard\":\"#FFFFFF\",\"colorBackgroundCardImage\":\"#000000\"}]").commit(); - } - } else { - data.edit().putString("themesjson", "[{\"colorPrimary\":\"#2196F3\",\"colorPrimaryDark\":\"#1769AA\",\"colorBackgroundText\":\"#000000\",\"colorBackground\":\"#FFFFFF\",\"colorButton\":\"#F50057\",\"shadow\":\"1\",\"colorHint\":\"#A8A8A8\",\"colorRipple\":\"#40000000\",\"colorPrimaryCardImage\":\"#000000\",\"version\":\"2\",\"colorPrimaryText\":\"#FFFFFF\",\"colorPrimaryImage\":\"#FFFFFF\",\"colorBackgroundImage\":\"#2196F3\",\"colorBackgroundCardText\":\"#000000\",\"statusbarIcon\":\"1\",\"colorBackgroundCard\":\"#FFFFFF\",\"colorButtonText\":\"#FFFFFF\",\"colorPrimaryCardText\":\"#000000\",\"colorPrimaryCard\":\"#FFFFFF\",\"colorBackgroundCardImage\":\"#000000\"}]").commit(); - } - } - if (data.getString("cookies", "").equals("0")) { - textview11.setVisibility(View.VISIBLE); - imageview1.setImageResource(R.drawable.no_network_emote02); - textview11.setText("GIVE ME BACK MY COOKIES!"); + welcome_text.setText("Seems like we're closing access to ZryteZene for maintenance, please try again later"); } - _checkCookie(); } - private boolean _checkPermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { - return (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) == PackageManager.PERMISSION_GRANTED); - } else { - return true; - } + private void retry() { + if (!nr) return; + nr = false; + getVersion(getApplicationContext()); } - @Override - public void onBackPressed() { - + private boolean checkVersion(DataSnapshot a) { + return a.child("mobile").getValue(String.class).equals("1"); } - @Override - public void onStart() { - super.onStart(); - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - private void _customSnack(final String _txt, final double _icon) { - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - layout.addView(snackview, 0); - snackbar.show(); - } - - - private void _randomEmoteUwU() { - textview3.setVisibility(View.GONE); - imageview2.setVisibility(View.GONE); - double _randomDouble = SketchwareUtil.getRandom(0, 11); - if (_randomDouble == 0) { - textview3.setText(":>"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 1) { - textview3.setText("UwU"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 2) { - textview3.setText("OwO"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 3) { - textview3.setText("^_^"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 4) { - textview3.setText(">_<"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 5) { - textview3.setText("'-'"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 6) { - textview3.setText("-,-"); - textview3.setVisibility(View.VISIBLE); - } - if (_randomDouble == 7) { - imageview2.setImageResource(R.drawable.no_network_emote01); - imageview2.setVisibility(View.VISIBLE); - } - if (_randomDouble == 8) { - imageview2.setImageResource(R.drawable.no_network_emote02); - imageview2.setVisibility(View.VISIBLE); - } - if (_randomDouble == 9) { - imageview2.setImageResource(R.drawable.no_network_emote03); - imageview2.setVisibility(View.VISIBLE); - } - if (_randomDouble == 10) { - imageview2.setImageResource(R.drawable.no_network_emote04); - imageview2.setVisibility(View.VISIBLE); - } - if (_randomDouble == 11) { - imageview2.setImageResource(R.drawable.no_network_emote05); - imageview2.setVisibility(View.VISIBLE); - } - } - - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - private void _chkChglog() { - if (data.getString("lastVersion", "").equals("")) { - _dispChglog(); - } else { - if ((double) packageInfo.versionCode > Double.parseDouble(data.getString("lastVersion", ""))) { - _dispChglog(); - } else { - activityChanger.setClass(getApplicationContext(), StreamingActivity.class); - startActivity(activityChanger); - finish(); - } - } - } - - - private void _dispChglog() { - d.setCancelable(false); - d.setTitle("ZryteZene ".concat(packageInfo.versionName.concat(" Changelog"))); - d.setMessage(tmpMapVar.get("msg").toString()); - d.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - data.edit().putString("lastVersion", String.valueOf((long) ((double) packageInfo.versionCode))).commit(); - activityChanger.setClass(getApplicationContext(), StreamingActivity.class); - startActivity(activityChanger); - finish(); - } - }); - d.create().show(); - } - - - private void _checkCookie() { - if (getApplicationContext().getPackageName().equals("tw.music.streamer")) { - update_db.addChildEventListener(_update_db_child_listener); - internetchecker.startRequestNetwork(RequestNetworkController.GET, "https://www.google.com", "A", _internetchecker_request_listener); - } else { - linear1.setVisibility(View.GONE); - linear7.setVisibility(View.VISIBLE); - } + private boolean checkPermissions() { + boolean a = true; + if (checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) a = false; + if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) && (ContextCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) != PackageManager.PERMISSION_GRANTED)) a = false; + return a; } - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); + private boolean checkAccount() { + return auth.getCurrentUser() != null; } - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; + private void openActivity(Class a) { + openActivity(a, null); } - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); + private void openActivity(Class a, String b) { + new Handler().postDelayed(() -> { + Intent intent = new Intent(getApplicationContext(), a); + if (b!=null) intent.putExtra("discord-server", b); + startActivity(intent); + finish(); + }, 2000); } -} +} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/MessageActivity.java b/app/src/main/java/tw/music/streamer/MessageActivity.java deleted file mode 100644 index f726823..0000000 --- a/app/src/main/java/tw/music/streamer/MessageActivity.java +++ /dev/null @@ -1,1126 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ClipData; -import android.content.ClipboardManager; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.ArrayAdapter; -import android.widget.BaseAdapter; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.bumptech.glide.Glide; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.database.ValueEventListener; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Calendar; -import java.util.HashMap; -import java.util.Random; - -public class MessageActivity extends AppCompatActivity { - - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - - private String keyTextChild = ""; - private HashMap map = new HashMap<>(); - private boolean isAdmin = false; - private HashMap roles_index = new HashMap<>(); - - private ArrayList> theme_map = new ArrayList<>(); - private ArrayList childKeys = new ArrayList<>(); - private ArrayList> commentMap = new ArrayList<>(); - private ArrayList adminsList = new ArrayList<>(); - private ArrayList profileList = new ArrayList<>(); - private ArrayList> profileMap = new ArrayList<>(); - private ArrayList dialog_list = new ArrayList<>(); - private ArrayList imgIndex = new ArrayList<>(); - private ArrayList> imgMap = new ArrayList<>(); - private ArrayList> rolesinfo_map = new ArrayList<>(); - private ArrayList rolesinfo_index = new ArrayList<>(); - - private LinearLayout linear1; - private ListView listview1; - private LinearLayout linear2; - private LinearLayout linear3; - private ImageView image_back; - private TextView text_title; - private EditText input_msg; - private ImageView image_send; - - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private DatabaseReference profile = _firebase.getReference("profile/text"); - private ChildEventListener _profile_child_listener; - private DatabaseReference profile_admins = _firebase.getReference("profile/admins"); - private ChildEventListener _profile_admins_child_listener; - private SharedPreferences data; - private DatabaseReference comments_db = _firebase.getReference("upload/msg"); - private ChildEventListener _comments_db_child_listener; - private Calendar cal = Calendar.getInstance(); - private AlertDialog.Builder d; - private Intent intent = new Intent(); - private DatabaseReference prof_img = _firebase.getReference("profile/image"); - private ChildEventListener _prof_img_child_listener; - private DatabaseReference prof_roles = _firebase.getReference("profile/roles"); - private ChildEventListener _prof_roles_child_listener; - private DatabaseReference prof_rolesinfo = _firebase.getReference("profile/rolesinfo"); - private ChildEventListener _prof_rolesinfo_child_listener; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.message); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - listview1 = findViewById(R.id.listview1); - linear2 = findViewById(R.id.linear2); - linear3 = findViewById(R.id.linear3); - image_back = findViewById(R.id.image_back); - text_title = findViewById(R.id.text_title); - input_msg = findViewById(R.id.input_msg); - image_send = findViewById(R.id.image_send); - Auth = FirebaseAuth.getInstance(); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - d = new AlertDialog.Builder(this); - - image_back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - input_msg.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - final String _charSeq = _param1.toString(); - int _maxHeightTemp = (int) SketchwareUtil.getDip(getApplicationContext(), 65); - if (input_msg.getHeight() >= _maxHeightTemp) { - linear3.getLayoutParams().height = _maxHeightTemp; - } else { - linear3.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); - } - } - - @Override - public void beforeTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - - } - - @Override - public void afterTextChanged(Editable _param1) { - - } - }); - - image_send.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (input_msg.getText().toString().trim().length() > 0) { - cal = Calendar.getInstance(); - map = new HashMap<>(); - map.put("key", keyTextChild); - map.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - map.put("msg", input_msg.getText().toString().trim()); - map.put("time", String.valueOf(cal.getTimeInMillis())); - comments_db.push().updateChildren(map); - _customSnack("Commented!", 1); - input_msg.setText(""); - } else { - _customSnack("Input is empty", 2); - } - } - }); - - _profile_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - profileList.add(_childKey); - profileMap.add(_childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - profile.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - profileMap = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - profileMap.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile.addChildEventListener(_profile_child_listener); - - _profile_admins_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - adminsList.add(_childKey); - if (FirebaseAuth.getInstance().getCurrentUser().getUid().equals(_childKey)) { - isAdmin = true; - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile_admins.addChildEventListener(_profile_admins_child_listener); - - _comments_db_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childValue.get("key").toString().equals(keyTextChild)) { - childKeys.add(0, _childKey); - commentMap.add(0, _childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (childKeys.contains(_childKey)) { - commentMap.remove(childKeys.indexOf(_childKey)); - childKeys.remove(childKeys.indexOf(_childKey)); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - comments_db.addChildEventListener(_comments_db_child_listener); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - imgIndex.add(_childKey); - imgMap.add(_childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - prof_img.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - imgMap = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - imgMap.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - - _prof_roles_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - roles_index.put(_childKey, _childValue.get("type").toString()); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_roles.addChildEventListener(_prof_roles_child_listener); - - _prof_rolesinfo_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - rolesinfo_index.add(_childValue.get("type").toString()); - rolesinfo_map.add(_childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(commentMap)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_rolesinfo.addChildEventListener(_prof_rolesinfo_child_listener); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - _loadTheme(); - keyTextChild = getIntent().getStringExtra("key"); - dialog_list.add("Profile"); - dialog_list.add("Delete"); - dialog_list.add("Copy"); - dialog_list.add("Cancel"); - text_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - input_msg.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - /* -Glide.with(getApplicationContext()).load(Uri.parse("lol")).into(image_back); -*/ - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private boolean isDark(int color) { - return androidx.core.graphics.ColorUtils.calculateLuminance(color) < 0.5; - } - - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_back); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_send); - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - if (isDark(Color.parseColor(theme_map.get(0).get("colorBackground").toString()))) { - linear2.setBackgroundColor(0xFF808080); - } else { - linear2.setBackgroundColor(0xFFBDBDBD); - } - } else { - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - } - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - listview1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - linear3.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - input_msg.setHintTextColor(Color.parseColor(theme_map.get(0).get("colorHint").toString())); - text_title.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - input_msg.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - image_back.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_send.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.MULTIPLY); - } - - - private void _rippleLib() { - } - - public void drawableclass() { - } - - private void _resetDialog() { - d = null; - d = new AlertDialog.Builder(this); - } - - private void _Linkify(final TextView _text, final String _color) { - _text.setClickable(true); - - android.text.util.Linkify.addLinks(_text, android.text.util.Linkify.ALL); - - _text.setLinkTextColor(Color.parseColor("#" + _color.replace("#", ""))); - - _text.setLinksClickable(true); - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public class Listview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Listview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.comments_layout, null); - } - - final LinearLayout linear_base = _v.findViewById(R.id.linear_base); - final ImageView imageview1 = _v.findViewById(R.id.imageview1); - final LinearLayout linear2 = _v.findViewById(R.id.linear2); - final LinearLayout linear1 = _v.findViewById(R.id.linear1); - final TextView textview2 = _v.findViewById(R.id.textview2); - final TextView textview1 = _v.findViewById(R.id.textview1); - final ImageView imageview2 = _v.findViewById(R.id.imageview2); - final TextView textview3 = _v.findViewById(R.id.textview3); - - cal.setTimeInMillis((long) (Double.parseDouble(commentMap.get(_position).get("time").toString()))); - linear_base.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - linear_base.setClickable(true); - if (adminsList.contains(commentMap.get(_position).get("uid").toString())) { - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - android.graphics.drawable.GradientDrawable _gD = new android.graphics.drawable.GradientDrawable(); - _gD.setColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - _gD.setShape(android.graphics.drawable.GradientDrawable.OVAL); - _gD.setStroke(5, Color.parseColor(theme_map.get(0).get("colorButton").toString())); - imageview1.setBackground(_gD); - } else { - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - imageview1.setBackgroundColor(Color.TRANSPARENT); - } - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview3.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (imgIndex.contains(commentMap.get(_position).get("uid").toString())) { - imageview1.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(imgMap.get(imgIndex.indexOf(commentMap.get(_position).get("uid").toString())).get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview1) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview1.setImageDrawable(circularBitmapDrawable); - } - }); - } else { - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview1.setImageResource(R.drawable.ic_person); - } - if (profileList.contains(commentMap.get(_position).get("uid").toString())) { - textview1.setText(profileMap.get(profileList.indexOf(commentMap.get(_position).get("uid").toString())).get("username").toString()); - } else { - textview1.setText(commentMap.get(_position).get("uid").toString()); - } - if (roles_index.containsKey(commentMap.get(_position).get("uid").toString())) { - imageview2.setVisibility(View.VISIBLE); - if (rolesinfo_index.contains(roles_index.get(commentMap.get(_position).get("uid").toString()).toString())) { - Glide.with(getApplicationContext()).load(Uri.parse(rolesinfo_map.get(rolesinfo_index.indexOf(roles_index.get(commentMap.get(_position).get("uid").toString()).toString())).get("img").toString())).into(imageview2); - } else { - imageview2.setImageResource(R.drawable.ic_unknown_roles); - } - } else { - imageview2.setVisibility(View.GONE); - } - textview2.setText(commentMap.get(_position).get("msg").toString()); - textview3.setText(new SimpleDateFormat("E, dd MMM yyyy HH:mm").format(cal.getTime())); - _Linkify(textview2, "#2196F3"); - linear_base.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _vlol) { - d.setCancelable(false); - d.setAdapter(new ArrayAdapter(MessageActivity.this, android.R.layout.simple_list_item_1, dialog_list), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dia, int _pos_dialog) { - _resetDialog(); - if (_pos_dialog == 0) { - intent.setClass(getApplicationContext(), ProfileActivity.class); - intent.putExtra("uid", commentMap.get(_position).get("uid").toString()); - startActivity(intent); - } else { - if (_pos_dialog == 1) { - if (commentMap.get(_position).get("uid").toString().equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) || isAdmin) { - d.setCancelable(false); - d.setTitle("Delete"); - d.setMessage("Are you sure to delete this comment?"); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - comments_db.child(childKeys.get(_position)).removeValue(); - _customSnack("Deleted!", 1); - _resetDialog(); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } else { - _customSnack("Can't delete! Access denied.", 2); - } - } else { - if (_pos_dialog == 2) { - ((ClipboardManager) getSystemService(getApplicationContext().CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("clipboard", commentMap.get(_position).get("msg").toString())); - _customSnack("Copied!", 1); - } else { - if (_pos_dialog == 3) { - - } - } - } - } - } - }); - - d.show(); - return true; - } - }); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - - return _v; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/PermissionsActivity.java b/app/src/main/java/tw/music/streamer/PermissionsActivity.java new file mode 100644 index 0000000..1c8bd4e --- /dev/null +++ b/app/src/main/java/tw/music/streamer/PermissionsActivity.java @@ -0,0 +1,80 @@ +package tw.music.streamer; + +import android.Manifest; +import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Bundle; +import android.os.Build; +import android.view.View; +import android.widget.TextView; +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.core.app.ActivityCompat; +import androidx.core.content.ContextCompat; + +import com.google.android.material.button.MaterialButton; + +public class PermissionsActivity extends AppCompatActivity { + + private static final int PERMISSION_REQUEST_CODE = 100; + private TextView pm1, pm2; + private MaterialButton rqpb; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.permissions); + pm1 = findViewById(R.id.pm1text); + pm2 = findViewById(R.id.pm2text); + rqpb = findViewById(R.id.pmbutton); + checkPermissions(); + rqpb.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (checkPerm1() && checkPerm2()) { + Intent intent = new Intent(getApplicationContext(), StreamingActivity.class); + startActivity(intent); + finish(); + } else { + requestPermissions(); + } + } + }); + } + + @Override + public void onStart() { + super.onStart(); + checkPermissions(); + } + + private void checkPermissions() { + if (checkPerm1()) pm1.setTextColor(getResources().getColor(android.R.color.holo_green_light)); + if (checkPerm2()) pm2.setTextColor(getResources().getColor(android.R.color.holo_green_light)); + } + + private boolean checkPerm1() { + return ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED; + } + + private boolean checkPerm2() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { + return ContextCompat.checkSelfPermission(this, Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) == PackageManager.PERMISSION_GRANTED; + } else { + return true; + } + } + + private void requestPermissions() { + ActivityCompat.requestPermissions(this, new String[]{ + Manifest.permission.POST_NOTIFICATIONS, + Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK + }, PERMISSION_REQUEST_CODE); + } + + @Override + public void onRequestPermissionsResult(int a, @NonNull String[] b, @NonNull int[] c) { + super.onRequestPermissionsResult(a, b, c); + if (a == PERMISSION_REQUEST_CODE) checkPermissions(); + } +} diff --git a/app/src/main/java/tw/music/streamer/ProfileActivity.java b/app/src/main/java/tw/music/streamer/ProfileActivity.java deleted file mode 100644 index 3e4844a..0000000 --- a/app/src/main/java/tw/music/streamer/ProfileActivity.java +++ /dev/null @@ -1,1340 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.ClipData; -import android.content.ClipboardManager; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Bitmap; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.text.InputType; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.PopupMenu; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.bumptech.glide.Glide; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.database.ValueEventListener; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; - -public class ProfileActivity extends AppCompatActivity { - - private Timer _timer = new Timer(); - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - - private String childKey = ""; - private HashMap map_var = new HashMap<>(); - private boolean isPictured = false; - private boolean isAdmin = false; - private boolean isBanned = false; - private String user_uid = ""; - private String user_email = ""; - private String currentusertype = ""; - private String thisusertype = ""; - private boolean isThisUserAdmin = false; - - private ArrayList> theme_map = new ArrayList<>(); - private ArrayList> rolesmap = new ArrayList<>(); - private ArrayList> roletmpmap = new ArrayList<>(); - - private LinearLayout linear1; - private ScrollView vscroll1; - private LinearLayout linear3; - private ImageView imageview_back; - private TextView textview_back; - private ImageView imageview_menu; - private LinearLayout linear2; - private LinearLayout linear4; - private LinearLayout linear6; - private TextView textview_bio; - private LinearLayout linear8; - private LinearLayout linear_name; - private LinearLayout linear_chgpass; - private LinearLayout linear_pic; - private LinearLayout linear_chgbio; - private LinearLayout linear_ban; - private LinearLayout linear7; - private LinearLayout linear_logout; - private LinearLayout linear_usr; - private LinearLayout linear5; - private ImageView imageview_usr; - private LinearLayout linear9; - private TextView textview_roles; - private TextView textview_usr; - private ImageView imageview_roles; - private ImageView imageview_name; - private TextView textview_name; - private ImageView imageview_chgpass; - private TextView textview_chgpass; - private ImageView imageview_pic; - private TextView textview_pic; - private ImageView imageview_chgbio; - private TextView textview_chgbio; - private ImageView imageview_ban; - private TextView textview_ban; - private ImageView imageview_logout; - private TextView textview_logout; - private TextView textview_loading; - - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private AlertDialog.Builder d; - private DatabaseReference profile = _firebase.getReference("profile/text"); - private ChildEventListener _profile_child_listener; - private AlertDialog.Builder dialog; - private DatabaseReference prof_img = _firebase.getReference("profile/image"); - private ChildEventListener _prof_img_child_listener; - private Intent i = new Intent(); - private SharedPreferences data; - private DatabaseReference prof_bans = _firebase.getReference("profile/bans"); - private ChildEventListener _prof_bans_child_listener; - private DatabaseReference profile_admins = _firebase.getReference("profile/admins"); - private ChildEventListener _profile_admins_child_listener; - private AlertDialog.Builder dban; - private DatabaseReference prof_roles = _firebase.getReference("profile/roles"); - private ChildEventListener _prof_roles_child_listener; - private DatabaseReference prof_rolesinfo = _firebase.getReference("profile/rolesinfo"); - private ChildEventListener _prof_rolesinfo_child_listener; - private TimerTask delay; - private PopupMenu _imageview_menu_popup; - private Menu _imageview_menu_menu; - private boolean _isListeningToAdmin = false; - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.profile); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - vscroll1 = findViewById(R.id.vscroll1); - linear3 = findViewById(R.id.linear3); - imageview_back = findViewById(R.id.imageview_back); - textview_back = findViewById(R.id.textview_back); - imageview_menu = findViewById(R.id.imageview_menu); - linear2 = findViewById(R.id.linear2); - linear4 = findViewById(R.id.linear4); - linear6 = findViewById(R.id.linear6); - textview_bio = findViewById(R.id.textview_bio); - linear8 = findViewById(R.id.linear8); - linear_name = findViewById(R.id.linear_name); - linear_chgpass = findViewById(R.id.linear_chgpass); - linear_pic = findViewById(R.id.linear_pic); - linear_chgbio = findViewById(R.id.linear_chgbio); - linear_ban = findViewById(R.id.linear_ban); - linear7 = findViewById(R.id.linear7); - linear_logout = findViewById(R.id.linear_logout); - linear_usr = findViewById(R.id.linear_usr); - linear5 = findViewById(R.id.linear5); - imageview_usr = findViewById(R.id.imageview_usr); - linear9 = findViewById(R.id.linear9); - textview_roles = findViewById(R.id.textview_roles); - textview_usr = findViewById(R.id.textview_usr); - imageview_roles = findViewById(R.id.imageview_roles); - imageview_name = findViewById(R.id.imageview_name); - textview_name = findViewById(R.id.textview_name); - imageview_chgpass = findViewById(R.id.imageview_chgpass); - textview_chgpass = findViewById(R.id.textview_chgpass); - imageview_pic = findViewById(R.id.imageview_pic); - textview_pic = findViewById(R.id.textview_pic); - imageview_chgbio = findViewById(R.id.imageview_chgbio); - textview_chgbio = findViewById(R.id.textview_chgbio); - imageview_ban = findViewById(R.id.imageview_ban); - textview_ban = findViewById(R.id.textview_ban); - imageview_logout = findViewById(R.id.imageview_logout); - textview_logout = findViewById(R.id.textview_logout); - textview_loading = findViewById(R.id.textview_loading); - Auth = FirebaseAuth.getInstance(); - d = new AlertDialog.Builder(this); - dialog = new AlertDialog.Builder(this); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - dban = new AlertDialog.Builder(this); - - imageview_back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - imageview_menu.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _imageview_menu_popup.show(); - } - }); - - linear_name.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - LinearLayout mylayout = new LinearLayout(ProfileActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(ProfileActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - myedittext.setText(textview_usr.getText().toString()); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Enter your new Username"); - dialog.setTitle("Change username"); - dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - if (myedittext.getText().toString().trim().equals("")) { - _customSnack("Fill those blanks!", 2); - } else { - map_var = new HashMap<>(); - map_var.put("profile", FirebaseAuth.getInstance().getCurrentUser().getEmail()); - map_var.put("username", myedittext.getText().toString().trim()); - map_var.put("bio", textview_bio.getText().toString()); - profile.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).updateChildren(map_var); - _customSnack("Username changed.", 1); - } - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - } - }); - dialog.create().show(); - } - }); - - linear_chgpass.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - d.setTitle("Change password?"); - d.setMessage("Are you sure to change your password?"); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - Auth.sendPasswordResetEmail(FirebaseAuth.getInstance().getCurrentUser().getEmail()).addOnCompleteListener(_Auth_reset_password_listener); - _customSnack("Check your e-mail to change your password.", 0); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - d.create().show(); - } - }); - - linear_pic.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isPictured) { - i.setClass(getApplicationContext(), ChgpicActivity.class); - i.putExtra("uid", getIntent().getStringExtra("uid")); - startActivity(i); - } else { - if (getIntent().getStringExtra("uid").equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - i.setClass(getApplicationContext(), FilepickerActivity.class); - i.putExtra("fileType", "image/*"); - startActivity(i); - } - } - } - }); - - linear_chgbio.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - LinearLayout mylayout = new LinearLayout(ProfileActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(ProfileActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setText(textview_bio.getText().toString()); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Hi, i'm using TeamMusic now!"); - dialog.setTitle("Change bio"); - dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - if (myedittext.getText().toString().trim().equals("")) { - _customSnack("Fill those blanks!", 2); - } else { - map_var = new HashMap<>(); - map_var.put("profile", FirebaseAuth.getInstance().getCurrentUser().getEmail()); - map_var.put("username", textview_usr.getText().toString()); - map_var.put("bio", myedittext.getText().toString().trim()); - profile.child(FirebaseAuth.getInstance().getCurrentUser().getUid()).updateChildren(map_var); - _customSnack("Bio changed.", 1); - } - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - } - }); - dialog.create().show(); - } - }); - - linear_ban.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isBanned) { - prof_bans.child(getIntent().getStringExtra("uid")).removeValue(); - } else { - - LinearLayout mylayout = new LinearLayout(ProfileActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(ProfileActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - - mylayout.addView(myedittext); - dban.setView(mylayout); - myedittext.setHint("Reason"); - dban.setTitle("Ban this user with following reason :"); - dban.setPositiveButton("Ban user", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - if (myedittext.getText().toString().trim().equals("")) { - _customSnack("Fill those blanks!", 2); - } else { - map_var = new HashMap<>(); - map_var.put("reason", myedittext.getText().toString().trim()); - map_var.put("banned", true); - prof_bans.child(getIntent().getStringExtra("uid")).updateChildren(map_var); - _customSnack("User banned.", 1); - } - } - }); - dban.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - } - }); - dban.create().show(); - } - } - }); - - linear_logout.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - FirebaseAuth.getInstance().signOut(); - finishAffinity(); - } - }); - - linear_usr.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isPictured) { - i.setClass(getApplicationContext(), ChgpicActivity.class); - i.putExtra("uid", getIntent().getStringExtra("uid")); - startActivity(i); - } else { - if (getIntent().getStringExtra("uid").equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - i.setClass(getApplicationContext(), FilepickerActivity.class); - i.putExtra("fileType", "image/*"); - startActivity(i); - } - } - } - }); - - _profile_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - user_uid = _childKey; - user_email = _childValue.get("profile").toString(); - textview_usr.setText(_childValue.get("username").toString()); - if (_childValue.containsKey("bio")) { - textview_bio.setText(_childValue.get("bio").toString()); - } else { - textview_bio.setText("Hi, i'm using ZryteZene now!"); - } - linear3.setVisibility(View.GONE); - vscroll1.setVisibility(View.VISIBLE); - imageview_menu.setVisibility(View.VISIBLE); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - textview_usr.setText(_childValue.get("username").toString()); - if (_childValue.containsKey("bio")) { - textview_bio.setText(_childValue.get("bio").toString()); - } else { - textview_bio.setText("Hi, i'm using ZryteZene now!"); - } - } - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile.addChildEventListener(_profile_child_listener); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - imageview_usr.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview_usr) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview_usr.setImageDrawable(circularBitmapDrawable); - } - }); - isPictured = true; - textview_pic.setText("View account picture"); - if (!getIntent().getStringExtra("uid").equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - linear_pic.setVisibility(View.VISIBLE); - } - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview_usr) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview_usr.setImageDrawable(circularBitmapDrawable); - } - }); - } - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - - _prof_bans_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - isBanned = true; - textview_ban.setText("Un-ban account"); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - isBanned = false; - textview_ban.setText("Ban account"); - } - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_bans.addChildEventListener(_prof_bans_child_listener); - - _profile_admins_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - isAdmin = true; - } - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - isThisUserAdmin = true; - android.graphics.drawable.GradientDrawable _gD = new android.graphics.drawable.GradientDrawable(); - _gD.setColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - _gD.setShape(android.graphics.drawable.GradientDrawable.OVAL); - _gD.setStroke(5, Color.parseColor(theme_map.get(0).get("colorButton").toString())); - imageview_usr.setBackground(_gD); - } - if (isAdmin && (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) || _childKey.equals(getIntent().getStringExtra("uid")))) { - linear_ban.setVisibility(View.GONE); - if (!getIntent().getStringExtra("uid").equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) && true) { - if (currentusertype.equals("0")) { - linear_ban.setVisibility(View.VISIBLE); - } else { - if (thisusertype.equals("")) { - if (currentusertype.equals("")) { - if (!isThisUserAdmin) { - linear_ban.setVisibility(View.VISIBLE); - } - } else { - linear_ban.setVisibility(View.VISIBLE); - } - } else { - if (!currentusertype.equals("")) { - if (Double.parseDouble(thisusertype) > Double.parseDouble(currentusertype)) { - linear_ban.setVisibility(View.VISIBLE); - } - } - } - } - } - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile_admins.addChildEventListener(_profile_admins_child_listener); - - _prof_roles_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(getIntent().getStringExtra("uid"))) { - thisusertype = _childValue.get("type").toString(); - imageview_roles.setVisibility(View.VISIBLE); - prof_rolesinfo.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - rolesmap = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - rolesmap.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - if (rolesmap.size() > 0) { - double _tmpNum = 0; - boolean _tmpBoolean = false; - for (int _repeat25 = 0; _repeat25 < rolesmap.size(); _repeat25++) { - if (rolesmap.get((int) _tmpNum).get("type").toString().equals(_childValue.get("type").toString())) { - textview_roles.setText(rolesmap.get((int) _tmpNum).get("name").toString()); - Glide.with(getApplicationContext()).load(Uri.parse(rolesmap.get((int) _tmpNum).get("img").toString())).into(imageview_roles); - textview_roles.setTextColor(Color.parseColor(rolesmap.get((int) _tmpNum).get("color").toString())); - _tmpBoolean = true; - } else { - if ((_tmpNum == (rolesmap.size() - 1)) && !_tmpBoolean) { - textview_roles.setText("Unknown role (".concat(_childValue.get("type").toString().concat(")"))); - imageview_roles.setImageResource(R.drawable.ic_unknown_roles); - } - } - _tmpNum++; - } - } else { - textview_roles.setText("Unknown role (".concat(_childValue.get("type").toString().concat(")"))); - } - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - currentusertype = _childValue.get("type").toString(); - } - if (!_isListeningToAdmin) { - _isListeningToAdmin = true; - profile_admins.addChildEventListener(_profile_admins_child_listener); - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_roles.addChildEventListener(_prof_roles_child_listener); - - _prof_rolesinfo_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_rolesinfo.addChildEventListener(_prof_rolesinfo_child_listener); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - _loadTheme(); - profile_admins.removeEventListener(_profile_admins_child_listener); - if (!getIntent().getStringExtra("uid").equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - linear_name.setVisibility(View.GONE); - linear_pic.setVisibility(View.GONE); - linear_chgpass.setVisibility(View.GONE); - linear_chgbio.setVisibility(View.GONE); - linear7.setVisibility(View.GONE); - linear_logout.setVisibility(View.GONE); - } - vscroll1.setVisibility(View.GONE); - linear_ban.setVisibility(View.GONE); - imageview_roles.setVisibility(View.GONE); - textview_back.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_usr.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_bio.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_name.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_pic.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_chgpass.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_logout.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_loading.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_roles.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_chgbio.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_ban.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_roles.setText("Member"); - imageview_menu.setVisibility(View.GONE); - _Linkify(textview_bio, "#2196F3"); - _imageview_menu_popup = new PopupMenu(ProfileActivity.this, imageview_menu); - - _imageview_menu_menu = _imageview_menu_popup.getMenu(); - _imageview_menu_menu.add("Copy uid"); - _imageview_menu_menu.add("Copy email"); - - - _imageview_menu_popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { - - public boolean onMenuItemClick(MenuItem item) { - switch (item.getTitle().toString()) { - case "Copy uid": - - ((ClipboardManager) getSystemService(getApplicationContext().CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("clipboard", user_uid)); - _customSnack("Copied!", 0); - return true; - - case "Copy email": - - ((ClipboardManager) getSystemService(getApplicationContext().CLIPBOARD_SERVICE)).setPrimaryClip(ClipData.newPlainText("clipboard", user_email)); - _customSnack("Copied!", 0); - return true; - - default: - return false; - } - } - }); - - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - if (!data.getString("tmpPath", "").equals("")) { - i.setClass(getApplicationContext(), CropActivity.class); - i.putExtra("path", data.getString("tmpPath", "")); - startActivity(i); - data.edit().remove("tmpPath").commit(); - finish(); - } - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private boolean isDark(int color) { - return androidx.core.graphics.ColorUtils.calculateLuminance(color) < 0.5; - } - - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _rippleEffect(final View _view, final String _color) { - _view.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(_color))); - _view.setClickable(true); - } - - - private void _rippleLib() { - } - - public void drawableclass() { - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview_back); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview_menu); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), linear_usr); - _rippleEffect(linear_name, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear_pic, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear_chgpass, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear_chgbio, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear_ban, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear_logout, theme_map.get(0).get("colorRipple").toString()); - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - if (isDark(Color.parseColor(theme_map.get(0).get("colorBackground").toString()))) { - linear6.setBackgroundColor(0xFF808080); - linear7.setBackgroundColor(0xFF808080); - linear8.setBackgroundColor(0xFF808080); - } else { - linear6.setBackgroundColor(0xFFBDBDBD); - linear7.setBackgroundColor(0xFFBDBDBD); - linear8.setBackgroundColor(0xFFBDBDBD); - } - } else { - linear6.setBackgroundColor(Color.TRANSPARENT); - linear7.setBackgroundColor(Color.TRANSPARENT); - linear8.setBackgroundColor(Color.TRANSPARENT); - } - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - vscroll1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - linear3.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - textview_back.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - textview_usr.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_roles.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_bio.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_name.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_pic.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_chgbio.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_ban.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_chgpass.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_logout.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview_loading.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview_name.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_pic.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_chgpass.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_chgbio.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_ban.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_logout.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_usr.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_back.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_menu.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - private void _Linkify(final TextView _text, final String _color) { - _text.setClickable(true); - - android.text.util.Linkify.addLinks(_text, android.text.util.Linkify.ALL); - - _text.setLinkTextColor(Color.parseColor("#" + _color.replace("#", ""))); - - _text.setLinksClickable(true); - } - - private void _abandonFocus() { - View _tmpView = this.getCurrentFocus(); - if (_tmpView != null) { - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(_tmpView.getWindowToken(), 0); - } - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/RegisterActivity.java b/app/src/main/java/tw/music/streamer/RegisterActivity.java new file mode 100644 index 0000000..1904e09 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/RegisterActivity.java @@ -0,0 +1,26 @@ +package tw.music.streamer; + +import android.content.Context; +import android.os.Bundle; +import android.view.View; +import android.text.TextUtils; +import android.content.Intent; +import android.widget.Toast; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.google.android.material.button.MaterialButton; +import com.google.android.material.textfield.TextInputEditText; + +import com.google.firebase.auth.FirebaseAuth; +import com.google.firebase.auth.FirebaseUser; + +public class RegisterActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle a) { + super.onCreate(a); + } + +} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/RequestNetwork.java b/app/src/main/java/tw/music/streamer/RequestNetwork.java deleted file mode 100644 index 1ecb8cc..0000000 --- a/app/src/main/java/tw/music/streamer/RequestNetwork.java +++ /dev/null @@ -1,53 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; - -import java.util.HashMap; - -public class RequestNetwork { - private HashMap params = new HashMap<>(); - private HashMap headers = new HashMap<>(); - - private Activity activity; - - private int requestType = 0; - - public RequestNetwork(Activity activity) { - this.activity = activity; - } - - public void setParams(HashMap params, int requestType) { - this.params = params; - this.requestType = requestType; - } - - public HashMap getParams() { - return params; - } - - public HashMap getHeaders() { - return headers; - } - - public void setHeaders(HashMap headers) { - this.headers = headers; - } - - public Activity getActivity() { - return activity; - } - - public int getRequestType() { - return requestType; - } - - public void startRequestNetwork(String method, String url, String tag, RequestListener requestListener) { - RequestNetworkController.getInstance().execute(this, method, url, tag, requestListener); - } - - public interface RequestListener { - void onResponse(String tag, String response); - - void onErrorResponse(String tag, String message); - } -} diff --git a/app/src/main/java/tw/music/streamer/RequestNetworkController.java b/app/src/main/java/tw/music/streamer/RequestNetworkController.java deleted file mode 100644 index 4fab447..0000000 --- a/app/src/main/java/tw/music/streamer/RequestNetworkController.java +++ /dev/null @@ -1,178 +0,0 @@ -package tw.music.streamer; - -import com.google.gson.Gson; - -import java.io.IOException; -import java.security.cert.CertificateException; -import java.util.HashMap; -import java.util.concurrent.TimeUnit; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.SSLContext; -import javax.net.ssl.SSLSession; -import javax.net.ssl.SSLSocketFactory; -import javax.net.ssl.TrustManager; -import javax.net.ssl.X509TrustManager; - -import okhttp3.Call; -import okhttp3.Callback; -import okhttp3.FormBody; -import okhttp3.Headers; -import okhttp3.HttpUrl; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; - -public class RequestNetworkController { - public static final String GET = "GET"; - public static final String POST = "POST"; - public static final String PUT = "PUT"; - public static final String DELETE = "DELETE"; - - public static final int REQUEST_PARAM = 0; - public static final int REQUEST_BODY = 1; - - private static final int SOCKET_TIMEOUT = 15000; - private static final int READ_TIMEOUT = 25000; - private static RequestNetworkController mInstance; - protected OkHttpClient client; - - public static synchronized RequestNetworkController getInstance() { - if (mInstance == null) { - mInstance = new RequestNetworkController(); - } - return mInstance; - } - - private OkHttpClient getClient() { - if (client == null) { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - - try { - final TrustManager[] trustAllCerts = new TrustManager[]{ - new X509TrustManager() { - @Override - public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) - throws CertificateException { - } - - @Override - public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) - throws CertificateException { - } - - @Override - public java.security.cert.X509Certificate[] getAcceptedIssuers() { - return new java.security.cert.X509Certificate[]{}; - } - } - }; - - final SSLContext sslContext = SSLContext.getInstance("TLS"); - sslContext.init(null, trustAllCerts, new java.security.SecureRandom()); - final SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory(); - builder.sslSocketFactory(sslSocketFactory, (X509TrustManager) trustAllCerts[0]); - builder.connectTimeout(SOCKET_TIMEOUT, TimeUnit.MILLISECONDS); - builder.readTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS); - builder.writeTimeout(READ_TIMEOUT, TimeUnit.MILLISECONDS); - builder.hostnameVerifier(new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }); - } catch (Exception e) { - } - - client = builder.build(); - } - - return client; - } - - public void execute(final RequestNetwork requestNetwork, String method, String url, final String tag, final RequestNetwork.RequestListener requestListener) { - Request.Builder reqBuilder = new Request.Builder(); - Headers.Builder headerBuilder = new Headers.Builder(); - - if (requestNetwork.getHeaders().size() > 0) { - HashMap headers = requestNetwork.getHeaders(); - - for (HashMap.Entry header : headers.entrySet()) { - headerBuilder.add(header.getKey(), String.valueOf(header.getValue())); - } - } - - try { - if (requestNetwork.getRequestType() == REQUEST_PARAM) { - if (method.equals(GET)) { - HttpUrl.Builder httpBuilder; - - try { - httpBuilder = HttpUrl.parse(url).newBuilder(); - } catch (NullPointerException ne) { - throw new NullPointerException("unexpected url: " + url); - } - - if (requestNetwork.getParams().size() > 0) { - HashMap params = requestNetwork.getParams(); - - for (HashMap.Entry param : params.entrySet()) { - httpBuilder.addQueryParameter(param.getKey(), String.valueOf(param.getValue())); - } - } - - reqBuilder.url(httpBuilder.build()).headers(headerBuilder.build()).get(); - } else { - FormBody.Builder formBuilder = new FormBody.Builder(); - if (requestNetwork.getParams().size() > 0) { - HashMap params = requestNetwork.getParams(); - - for (HashMap.Entry param : params.entrySet()) { - formBuilder.add(param.getKey(), String.valueOf(param.getValue())); - } - } - - RequestBody reqBody = formBuilder.build(); - - reqBuilder.url(url).headers(headerBuilder.build()).method(method, reqBody); - } - } else { - RequestBody reqBody = RequestBody.create(okhttp3.MediaType.parse("application/json"), new Gson().toJson(requestNetwork.getParams())); - - if (method.equals(GET)) { - reqBuilder.url(url).headers(headerBuilder.build()).get(); - } else { - reqBuilder.url(url).headers(headerBuilder.build()).method(method, reqBody); - } - } - - Request req = reqBuilder.build(); - - getClient().newCall(req).enqueue(new Callback() { - @Override - public void onFailure(Call call, final IOException e) { - requestNetwork.getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - requestListener.onErrorResponse(tag, e.getMessage()); - } - }); - } - - @Override - public void onResponse(Call call, final Response response) throws IOException { - final String responseBody = response.body().string().trim(); - requestNetwork.getActivity().runOnUiThread(new Runnable() { - @Override - public void run() { - requestListener.onResponse(tag, responseBody); - } - }); - } - }); - } catch (Exception e) { - requestListener.onErrorResponse(tag, e.getMessage()); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/SettingsActivity.java b/app/src/main/java/tw/music/streamer/SettingsActivity.java deleted file mode 100644 index e41352b..0000000 --- a/app/src/main/java/tw/music/streamer/SettingsActivity.java +++ /dev/null @@ -1,904 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.view.Window; -import android.view.WindowManager; -import android.widget.CompoundButton; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.RadioButton; -import android.widget.RadioGroup; -import android.widget.ScrollView; -import android.widget.SeekBar; -import android.widget.Switch; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Random; - -public class SettingsActivity extends AppCompatActivity { - - - private ArrayList> theme_map = new ArrayList<>(); - - private LinearLayout linear1; - private ScrollView vscroll1; - private ImageView imageview1; - private TextView textview1; - private LinearLayout linear2; - private Switch switch1; - private LinearLayout linear3; - private TextView textview2; - private EditText edittext1; - private LinearLayout linear4; - private LinearLayout linear6; - private LinearLayout linear7; - private LinearLayout linear11; - private LinearLayout linear12; - private LinearLayout linear13; - private LinearLayout linear14; - private LinearLayout linear15; - private LinearLayout linear16; - private Switch switch2; - private LinearLayout linear17; - private LinearLayout linear8; - private LinearLayout linear9; - private LinearLayout linear10; - private ImageView imageview2; - private LinearLayout linear5; - private TextView textview3; - private SeekBar seekbar1; - private TextView textview7; - private TextView textview8; - private TextView textview9; - private SeekBar seekbar2; - private ImageView imageview3; - private TextView textview4; - private ImageView imageview4; - private TextView textview5; - private ImageView imageview5; - private TextView textview6; - - private SharedPreferences data; - private Intent intent = new Intent(); - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private RadioButton radiobutton1; - private RadioButton radiobutton2; - private RadioGroup radiogroup1; - private RadioButton radiobutton3; - private RadioButton radiobutton4; - private RadioGroup radiogroup2; - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.settings); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - vscroll1 = findViewById(R.id.vscroll1); - imageview1 = findViewById(R.id.imageview1); - textview1 = findViewById(R.id.textview1); - linear2 = findViewById(R.id.linear2); - switch1 = findViewById(R.id.switch1); - linear3 = findViewById(R.id.linear3); - textview2 = findViewById(R.id.textview2); - edittext1 = findViewById(R.id.edittext1); - linear4 = findViewById(R.id.linear4); - linear6 = findViewById(R.id.linear6); - linear7 = findViewById(R.id.linear7); - linear11 = findViewById(R.id.linear11); - linear12 = findViewById(R.id.linear12); - linear13 = findViewById(R.id.linear13); - linear14 = findViewById(R.id.linear14); - linear15 = findViewById(R.id.linear15); - linear16 = findViewById(R.id.linear16); - switch2 = findViewById(R.id.switch2); - linear17 = findViewById(R.id.linear17); - linear8 = findViewById(R.id.linear8); - linear9 = findViewById(R.id.linear9); - linear10 = findViewById(R.id.linear10); - imageview2 = findViewById(R.id.imageview2); - linear5 = findViewById(R.id.linear5); - textview3 = findViewById(R.id.textview3); - seekbar1 = findViewById(R.id.seekbar1); - textview7 = findViewById(R.id.textview7); - textview8 = findViewById(R.id.textview8); - textview9 = findViewById(R.id.textview9); - seekbar2 = findViewById(R.id.seekbar2); - imageview3 = findViewById(R.id.imageview3); - textview4 = findViewById(R.id.textview4); - imageview4 = findViewById(R.id.imageview4); - textview5 = findViewById(R.id.textview5); - imageview5 = findViewById(R.id.imageview5); - textview6 = findViewById(R.id.textview6); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - Auth = FirebaseAuth.getInstance(); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - finish(); - } - }); - - switch1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton _param1, boolean _param2) { - final boolean _isChecked = _param2; - if (_isChecked) { - data.edit().putString("showPreview", "1").commit(); - switch1.getThumbDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - switch1.getTrackDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - } else { - data.edit().putString("showPreview", "0").commit(); - switch1.getThumbDrawable().clearColorFilter(); - switch1.getTrackDrawable().clearColorFilter(); - } - } - }); - - edittext1.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - final String _charSeq = _param1.toString(); - data.edit().putString("apiKey", _charSeq).commit(); - } - - @Override - public void beforeTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - - } - - @Override - public void afterTextChanged(Editable _param1) { - - } - }); - - switch2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton _param1, boolean _param2) { - final boolean _isChecked = _param2; - if (_isChecked) { - data.edit().putString("showVisualizer", "1").commit(); - switch2.getThumbDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - switch2.getTrackDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - } else { - data.edit().putString("showVisualizer", "0").commit(); - switch2.getThumbDrawable().clearColorFilter(); - switch2.getTrackDrawable().clearColorFilter(); - } - } - }); - - linear8.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), ProfileActivity.class); - intent.putExtra("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - startActivity(intent); - } - }); - - linear9.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), LogcatActivity.class); - startActivity(intent); - } - }); - - linear10.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), DaeditActivity.class); - startActivity(intent); - } - }); - - seekbar2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _param2, boolean _param3) { - final int _progressValue = _param2; - data.edit().putString("colorTransparency", String.valueOf((long) (seekbar2.getProgress()))).commit(); - textview9.setText("FPU alpha color: ".concat(data.getString("colorTransparency", ""))); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - - } - - @Override - public void onStopTrackingTouch(SeekBar _param2) { - - } - }); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - radiogroup1 = new RadioGroup(this); - radiogroup1.setOrientation(RadioGroup.VERTICAL); - radiobutton1 = new RadioButton(this); - radiobutton1.setText("Full-screen blurred styled"); - radiobutton1.setId(0); - radiobutton2 = new RadioButton(this); - radiobutton2.setText("Compact bottom-sheet styled"); - radiobutton2.setId(1); - radiogroup1.addView(radiobutton1); - radiogroup1.addView(radiobutton2); - linear11.addView(radiogroup1); - radiogroup1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - public void onCheckedChanged(RadioGroup group, int checkedId) { - data.edit().putString("playerUI", String.valueOf((long) (checkedId))).commit(); - if (checkedId == 0) { - radiobutton3.setEnabled(true); - radiobutton4.setEnabled(true); - linear13.setAlpha((float) (1.0d)); - } else { - radiobutton3.setEnabled(false); - radiobutton4.setEnabled(false); - linear13.setAlpha((float) (0.5d)); - } - } - }); - - radiogroup2 = new RadioGroup(this); - radiogroup2.setOrientation(RadioGroup.VERTICAL); - radiobutton3 = new RadioButton(this); - radiobutton3.setText("Blur image and set buttons & other controls color from detecting light on dominants color"); - radiobutton3.setId(0); - radiobutton4 = new RadioButton(this); - radiobutton4.setText("Blur image with color effect from current theme and set buttons & other controls color from current theme"); - radiobutton4.setId(1); - radiogroup2.addView(radiobutton3); - radiogroup2.addView(radiobutton4); - linear13.addView(radiogroup2); - radiogroup2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { - public void onCheckedChanged(RadioGroup group, int checkedId) { - data.edit().putString("fpuMode", String.valueOf((long) (checkedId))).commit(); - if (checkedId == 0) { - seekbar2.setEnabled(false); - linear15.setAlpha((float) (0.5d)); - } else { - seekbar2.setEnabled(true); - linear15.setAlpha((float) (1.0d)); - } - } - }); - _loadTheme(); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - switch1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - switch2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - edittext1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview5.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview6.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview7.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview8.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview9.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - radiobutton1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - radiobutton2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - radiobutton3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - radiobutton4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - seekbar1.setProgress((int) Double.parseDouble(data.getString("nightcoreSpeed", ""))); - textview3.setText("Nightcore Speed: ".concat(new DecimalFormat("0.00").format(1.10d + (0.05d * Double.parseDouble(data.getString("nightcoreSpeed", "")))).concat("x"))); - seekbar2.setProgress((int) Double.parseDouble(data.getString("colorTransparency", ""))); - if (data.getString("showPreview", "").equals("1")) { - switch1.setChecked(true); - } else { - switch1.setChecked(false); - } - if (data.getString("showVisualizer", "").equals("1")) { - switch2.setChecked(true); - } else { - switch2.setChecked(false); - } - edittext1.setText(data.getString("apiKey", "")); - seekbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _progressValue, boolean _param3) { - data.edit().putString("nightcoreSpeed", String.valueOf((long) (seekbar1.getProgress()))).commit(); - textview3.setText("Nightcore Speed: ".concat(new DecimalFormat("0.00").format(1.10d + (0.05d * Double.parseDouble(data.getString("nightcoreSpeed", "")))).concat("x"))); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - } - - @Override - public void onStopTrackingTouch(SeekBar _param1) { - } - }); - if (data.getString("playerUI", "").equals("0")) { - radiogroup1.check(radiobutton1.getId()); - } else { - radiogroup1.check(radiobutton2.getId()); - } - if (data.getString("fpuMode", "").equals("0")) { - radiogroup2.check(radiobutton3.getId()); - } else { - radiogroup2.check(radiobutton4.getId()); - } - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private boolean isDark(int color) { - return androidx.core.graphics.ColorUtils.calculateLuminance(color) < 0.5; - } - - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview1); - _rippleEffect(linear8, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear9, theme_map.get(0).get("colorRipple").toString()); - _rippleEffect(linear10, theme_map.get(0).get("colorRipple").toString()); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - if (isDark(Color.parseColor(theme_map.get(0).get("colorBackground").toString()))) { - linear3.setBackgroundColor(0xFF808080); - linear4.setBackgroundColor(0xFF808080); - linear7.setBackgroundColor(0xFF808080); - linear12.setBackgroundColor(0xFF808080); - linear14.setBackgroundColor(0xFF808080); - linear16.setBackgroundColor(0xFF808080); - linear17.setBackgroundColor(0xFF808080); - } else { - linear3.setBackgroundColor(0xFFBDBDBD); - linear4.setBackgroundColor(0xFFBDBDBD); - linear7.setBackgroundColor(0xFFBDBDBD); - linear12.setBackgroundColor(0xFFBDBDBD); - linear14.setBackgroundColor(0xFFBDBDBD); - linear16.setBackgroundColor(0xFFBDBDBD); - linear17.setBackgroundColor(0xFFBDBDBD); - } - } else { - linear3.setBackgroundColor(Color.TRANSPARENT); - linear4.setBackgroundColor(Color.TRANSPARENT); - linear7.setBackgroundColor(Color.TRANSPARENT); - linear12.setBackgroundColor(Color.TRANSPARENT); - linear14.setBackgroundColor(Color.TRANSPARENT); - linear16.setBackgroundColor(Color.TRANSPARENT); - linear17.setBackgroundColor(Color.TRANSPARENT); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - vscroll1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview3.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview4.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview5.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview6.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview7.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview8.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - textview9.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - radiobutton1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - radiobutton2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - radiobutton3.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - radiobutton4.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - { - android.content.res.ColorStateList colorStateList = new android.content.res.ColorStateList( - new int[][]{ - new int[]{-android.R.attr.state_enabled}, - new int[]{android.R.attr.state_enabled} - }, - new int[]{ - Color.parseColor(theme_map.get(0).get("colorButton").toString()), - Color.parseColor(theme_map.get(0).get("colorButton").toString()) - } - ); - radiobutton1.setButtonTintList(colorStateList); - radiobutton1.invalidate(); - } - - { - android.content.res.ColorStateList colorStateList = new android.content.res.ColorStateList( - new int[][]{ - new int[]{-android.R.attr.state_enabled}, - new int[]{android.R.attr.state_enabled} - }, - new int[]{ - Color.parseColor(theme_map.get(0).get("colorButton").toString()), - Color.parseColor(theme_map.get(0).get("colorButton").toString()) - } - ); - radiobutton2.setButtonTintList(colorStateList); - radiobutton2.invalidate(); - } - - { - android.content.res.ColorStateList colorStateList = new android.content.res.ColorStateList( - new int[][]{ - new int[]{-android.R.attr.state_enabled}, - new int[]{android.R.attr.state_enabled} - }, - new int[]{ - Color.parseColor(theme_map.get(0).get("colorButton").toString()), - Color.parseColor(theme_map.get(0).get("colorButton").toString()) - } - ); - radiobutton3.setButtonTintList(colorStateList); - radiobutton3.invalidate(); - } - - { - android.content.res.ColorStateList colorStateList = new android.content.res.ColorStateList( - new int[][]{ - new int[]{-android.R.attr.state_enabled}, - new int[]{android.R.attr.state_enabled} - }, - new int[]{ - Color.parseColor(theme_map.get(0).get("colorButton").toString()), - Color.parseColor(theme_map.get(0).get("colorButton").toString()) - } - ); - radiobutton4.setButtonTintList(colorStateList); - radiobutton4.invalidate(); - } - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - radiobutton1.setBackground(ripdrb); - } - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - radiobutton2.setBackground(ripdrb); - } - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - radiobutton3.setBackground(ripdrb); - } - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - radiobutton4.setBackground(ripdrb); - } - switch1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - switch2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - edittext1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - edittext1.setHintTextColor(Color.parseColor(theme_map.get(0).get("colorHint").toString())); - seekbar1.getProgressDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - - seekbar1.getThumb().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - seekbar1.setBackground(ripdrb); - } - - seekbar2.getProgressDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - - seekbar2.getThumb().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - seekbar2.setBackground(ripdrb); - } - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - switch1.setBackground(ripdrb); - } - - { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(theme_map.get(0).get("colorRipple").toString())}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - switch2.setBackground(ripdrb); - } - edittext1.getBackground().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_ATOP); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview2.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview3.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview4.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview5.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - - private void _rippleEffect(final View _view, final String _color) { - _view.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(_color))); - _view.setClickable(true); - } - - public void drawableclass() { - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/SketchApplication.java b/app/src/main/java/tw/music/streamer/SketchApplication.java deleted file mode 100644 index 8bd2375..0000000 --- a/app/src/main/java/tw/music/streamer/SketchApplication.java +++ /dev/null @@ -1,63 +0,0 @@ -package tw.music.streamer; - -import android.app.AlarmManager; -import android.app.Application; -import android.app.PendingIntent; -import android.content.Context; -import android.content.Intent; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.Writer; - -public class SketchApplication extends Application { - - - private Thread.UncaughtExceptionHandler uncaughtExceptionHandler; - - @Override - public void onCreate() { - - this.uncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler(); - - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread thread, Throwable ex) { - Intent intent = new Intent(getApplicationContext(), DebugActivity.class); - intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); - - intent.putExtra("error", getStackTrace(ex)); - - PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 11111, intent, PendingIntent.FLAG_ONE_SHOT); - - - AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); - am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, 1000, pendingIntent); - - android.os.Process.killProcess(android.os.Process.myPid()); - System.exit(2); - - uncaughtExceptionHandler.uncaughtException(thread, ex); - } - }); - super.onCreate(); - - } - - - private String getStackTrace(Throwable th) { - final Writer result = new StringWriter(); - - final PrintWriter printWriter = new PrintWriter(result); - Throwable cause = th; - - while (cause != null) { - cause.printStackTrace(printWriter); - cause = cause.getCause(); - } - final String stacktraceAsString = result.toString(); - printWriter.close(); - - return stacktraceAsString; - } -} diff --git a/app/src/main/java/tw/music/streamer/SketchwareUtil.java b/app/src/main/java/tw/music/streamer/SketchwareUtil.java deleted file mode 100644 index 4f9ec8d..0000000 --- a/app/src/main/java/tw/music/streamer/SketchwareUtil.java +++ /dev/null @@ -1,71 +0,0 @@ -package tw.music.streamer; - -import android.content.Context; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.widget.ListView; -import android.widget.Toast; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.Random; - -public class SketchwareUtil { - public static void showMessage(Context _context, String _s) { - Toast.makeText(_context, _s, Toast.LENGTH_SHORT).show(); - } - - public static int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - public static int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - public static int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - public static ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - public static float getDip(Context _context, int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, _context.getResources().getDisplayMetrics()); - } - - public static int getDisplayWidthPixels(Context _context) { - return _context.getResources().getDisplayMetrics().widthPixels; - } - - public static int getDisplayHeightPixels(Context _context) { - return _context.getResources().getDisplayMetrics().heightPixels; - } - - public static void getAllKeysFromMap(Map map, ArrayList output) { - if (output == null) return; - output.clear(); - - if (map == null || map.size() <= 0) return; - - Iterator itr = map.entrySet().iterator(); - while (itr.hasNext()) { - Map.Entry entry = (Map.Entry) itr.next(); - output.add(entry.getKey()); - } - } -} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/StreamerActivity.java b/app/src/main/java/tw/music/streamer/StreamerActivity.java deleted file mode 100644 index 81e1470..0000000 --- a/app/src/main/java/tw/music/streamer/StreamerActivity.java +++ /dev/null @@ -1,3263 +0,0 @@ -package tw.music.streamer; - -import android.Manifest; -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ObjectAnimator; -import android.animation.TimeInterpolator; -import android.animation.ValueAnimator; -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.app.DownloadManager; -import android.app.ProgressDialog; -import android.content.ComponentName; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.ServiceConnection; -import android.content.IntentFilter; -import android.content.BroadcastReceiver; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Outline; -import android.graphics.Paint; -import android.graphics.Path; -import android.graphics.PixelFormat; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffColorFilter; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.graphics.Region; -import android.graphics.Typeface; -import android.media.AudioManager; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.os.Environment; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; -import android.text.DynamicLayout; -import android.text.Editable; -import android.text.InputType; -import android.text.Layout; -import android.text.SpannableStringBuilder; -import android.text.StaticLayout; -import android.text.TextPaint; -import android.text.TextUtils; -import android.text.TextWatcher; -import android.util.DisplayMetrics; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.Gravity; -import android.view.KeyEvent; -import android.view.LayoutInflater; -import android.view.MotionEvent; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewManager; -import android.view.ViewOutlineProvider; -import android.view.ViewTreeObserver; -import android.view.Window; -import android.view.WindowManager; -import android.view.animation.AccelerateDecelerateInterpolator; -import android.view.animation.DecelerateInterpolator; -import android.view.animation.TranslateAnimation; -import android.webkit.URLUtil; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.BaseAdapter; -import android.widget.EditText; -import android.widget.GridLayout; -import android.widget.GridView; -import android.widget.HorizontalScrollView; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ProgressBar; -import android.widget.ScrollView; -import android.widget.SeekBar; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.ActionBarDrawerToggle; -import androidx.appcompat.app.AppCompatActivity; -import androidx.appcompat.widget.Toolbar; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; -import androidx.core.view.GravityCompat; -import androidx.drawerlayout.widget.DrawerLayout; - -import com.bumptech.glide.Glide; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.android.gms.tasks.Task; -import com.google.android.material.tabs.TabLayout; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.database.ValueEventListener; -import com.google.firebase.storage.FileDownloadTask; -import com.google.firebase.storage.FirebaseStorage; -import com.google.firebase.storage.OnProgressListener; -import com.google.firebase.storage.StorageReference; -import com.google.firebase.storage.UploadTask; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.io.File; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Random; - -import tw.music.streamer.adaptor.ZryteZeneAdaptor; -import tw.music.streamer.service.ZryteZenePlay; - -public class StreamerActivity extends AppCompatActivity { - - private Toolbar _toolbar; - private DrawerLayout _drawer; - private HashMap likes_map = new HashMap<>(); - private HashMap commentsMap = new HashMap<>(); - private boolean isAdmin = false; - private String currentlyPlaying = ""; - private HashMap upload_map = new HashMap<>(); - private double tabsPos = 0; - private double openNum = 0; - private boolean isPlaylist = false; - private double numPlaylist = 0; - private boolean isSearching = false; - private boolean hasPic = false; - private HashMap img_maps = new HashMap<>(); - private HashMap tempMap; - - private ArrayList usrname_list = new ArrayList<>(); - private ArrayList> upload_list = new ArrayList<>(); - private ArrayList> theme_map = new ArrayList<>(); - private ArrayList adminsList = new ArrayList<>(); - private ArrayList> like_tmp = new ArrayList<>(); - private ArrayList> profile_map = new ArrayList<>(); - private ArrayList likeChild = new ArrayList<>(); - private ArrayList childkey = new ArrayList<>(); - private ArrayList oldChildKey = new ArrayList<>(); - private ArrayList> oldListmap = new ArrayList<>(); - private ArrayList commentsChildKey = new ArrayList<>(); - private ArrayList> commentsTmp = new ArrayList<>(); - private ArrayList dialog_list = new ArrayList<>(); - private ArrayList currentlyChild = new ArrayList<>(); - private ArrayList> currentlyMap = new ArrayList<>(); - private ArrayList playlistString = new ArrayList<>(); - private ArrayList> playlistMap = new ArrayList<>(); - private ArrayList> playKeys = new ArrayList<>(); - private ArrayList animateList = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private LinearLayout linear_title; - private LinearLayout linear_data; - private ListView listview1; - private LinearLayout linear_title2; - private LinearLayout linear_title_shdw; - private ImageView image_drawer; - private TextView text_zryte; - private TextView text_zene; - private TextView text_playlist; - private EditText edittext_search; - private ImageView image_search; - private ImageView image_user; - private TextView text_data; - private ProgressBar progressbar1; - private LinearLayout linear3; - private LinearLayout linear5; - private LinearLayout linear6; - private HorizontalScrollView hscroll1; - private ImageView image_menu; - private LinearLayout linear16; - private ImageView image_favs; - private ImageView image_comment; - private ImageView image_repeat; - private ImageView image_nightcore; - private ImageView image_download; - private ImageView image_lyrics; - private ImageView image_share; - private LinearLayout linear7; - private LinearLayout linear8; - private SeekBar seekbar1; - private LinearLayout linear9; - private LinearLayout linear12; - private LinearLayout linear15; - private ImageView image_album; - private LinearLayout linear14; - private LinearLayout linear13; - private TextView text_title; - private TextView text_artist; - private TextView text_current; - private LinearLayout linear10; - private LinearLayout linear11; - private TextView text_duration; - private ImageView image_prev; - private ImageView image_play; - private ImageView image_next; - private LinearLayout _drawer_linear1; - private ScrollView _drawer_vscroll1; - private LinearLayout _drawer_linear10; - private LinearLayout _drawer_linear_usr; - private LinearLayout _drawer_linear2; - private LinearLayout _drawer_linear6; - private LinearLayout _drawer_linear_upload; - private LinearLayout _drawer_linear7; - private LinearLayout _drawer_linear_theme; - private LinearLayout _drawer_linear_themesstr; - private LinearLayout _drawer_linear8; - private LinearLayout _drawer_linear_info; - private LinearLayout _drawer_linear_discord; - private LinearLayout _drawer_linear_settings; - private LinearLayout _drawer_linear9; - private LinearLayout _drawer_linear_daedit; - private LinearLayout _drawer_linear_logcat; - private ImageView _drawer_imageview_tm; - private TextView _drawer_text_zryte; - private TextView _drawer_text_zene; - private ImageView _drawer_imageview_upload; - private TextView _drawer_text_upload; - private ImageView _drawer_imageview_theme; - private TextView _drawer_text_theme; - private ImageView _drawer_imageview_themesstr; - private TextView _drawer_text_themesstr; - private ImageView _drawer_imageview_info; - private TextView _drawer_text_info; - private ImageView _drawer_imageview_discord; - private TextView _drawer_text_discord; - private ImageView _drawer_imageview_settings; - private TextView _drawer_text_settings; - private ImageView _drawer_imageview_daedit; - private TextView _drawer_text_daedit; - private ImageView _drawer_imageview_logcat; - private TextView _drawer_text_logcat; - private ImageView _drawer_image_user; - private LinearLayout _drawer_linear_usr2; - private TextView _drawer_text_user; - private TextView _drawer_text_email; - - private ObjectAnimator obj = new ObjectAnimator(); - private ObjectAnimator obj2 = new ObjectAnimator(); - private ObjectAnimator obj3 = new ObjectAnimator(); - private SharedPreferences data; - private DatabaseReference upload_text; - private ChildEventListener _upload_text_child_listener; - private DatabaseReference profile_admins; - private ChildEventListener _profile_admins_child_listener; - private DatabaseReference comments_db; - private ChildEventListener _comments_db_child_listener; - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private DatabaseReference profile; - private ChildEventListener _profile_child_listener; - private DatabaseReference fb_likes; - private ChildEventListener _fb_likes_child_listener; - private DatabaseReference prof_img; - private ChildEventListener _prof_img_child_listener; - private Intent intent = new Intent(); - private AlertDialog.Builder d; - private Intent i2 = new Intent(); - private StorageReference check_quota; - private OnCompleteListener _check_quota_upload_success_listener; - private OnSuccessListener _check_quota_download_success_listener; - private OnSuccessListener _check_quota_delete_success_listener; - private OnProgressListener _check_quota_upload_progress_listener; - private OnProgressListener _check_quota_download_progress_listener; - private OnFailureListener _check_quota_failure_listener; - private StorageReference upload_storage; - private OnCompleteListener _upload_storage_upload_success_listener; - private OnSuccessListener _upload_storage_download_success_listener; - private OnSuccessListener _upload_storage_delete_success_listener; - private OnProgressListener _upload_storage_upload_progress_listener; - private OnProgressListener _upload_storage_download_progress_listener; - private OnFailureListener _upload_storage_failure_listener; - private StorageReference music_image; - private OnCompleteListener _music_image_upload_success_listener; - private OnSuccessListener _music_image_download_success_listener; - private OnSuccessListener _music_image_delete_success_listener; - private OnProgressListener _music_image_upload_progress_listener; - private OnProgressListener _music_image_download_progress_listener; - private OnFailureListener _music_image_failure_listener; - private ObjectAnimator obj4 = new ObjectAnimator(); - private ObjectAnimator obj5 = new ObjectAnimator(); - private ObjectAnimator obj6 = new ObjectAnimator(); - private double _f; - private double _t; - private ArrayAdapter Listview2Adapter; - private GridView listview2; - private com.google.android.material.tabs.TabLayout x_tab; - private androidx.viewpager.widget.ViewPager viewPager; - private android.graphics.drawable.AnimationDrawable rocketAnimation; - private ProgressDialog coreprog; - private ZryteZeneAdaptor zz; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.streamer); - initFirebase(); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initFirebase() { - Auth = FirebaseAuth.getInstance(); - upload_text = FirebaseDatabase.getInstance().getReference("upload/text"); - profile_admins = FirebaseDatabase.getInstance().getReference("profile/admins"); - comments_db = FirebaseDatabase.getInstance().getReference("upload/msg"); - profile = FirebaseDatabase.getInstance().getReference("profile/text"); - fb_likes = FirebaseDatabase.getInstance().getReference("upload/likes"); - prof_img = FirebaseDatabase.getInstance().getReference("profile/image"); - check_quota = FirebaseStorage.getInstance().getReference("/"); - upload_storage = FirebaseStorage.getInstance().getReference("upload/music"); - music_image = FirebaseStorage.getInstance().getReference("upload/image"); - } - - private void initialize(Bundle _savedInstanceState) { - _toolbar = findViewById(R.id._toolbar); - setSupportActionBar(_toolbar); - getSupportActionBar().setDisplayHomeAsUpEnabled(true); - getSupportActionBar().setHomeButtonEnabled(true); - _toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _v) { - onBackPressed(); - } - }); - _drawer = findViewById(R.id._drawer); - ActionBarDrawerToggle _toggle = new ActionBarDrawerToggle(StreamerActivity.this, _drawer, _toolbar, R.string.app_name, R.string.app_name); - _drawer.addDrawerListener(_toggle); - _toggle.syncState(); - - LinearLayout _nav_view = findViewById(R.id._nav_view); - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - linear_title = findViewById(R.id.linear_title); - linear_data = findViewById(R.id.linear_data); - listview1 = findViewById(R.id.listview1); - linear_title2 = findViewById(R.id.linear_title2); - linear_title_shdw = findViewById(R.id.linear_title_shdw); - image_drawer = findViewById(R.id.image_drawer); - text_zryte = findViewById(R.id.text_zryte); - text_zene = findViewById(R.id.text_zene); - text_playlist = findViewById(R.id.text_playlist); - edittext_search = findViewById(R.id.edittext_search); - image_search = findViewById(R.id.image_search); - image_user = findViewById(R.id.image_user); - text_data = findViewById(R.id.text_data); - progressbar1 = findViewById(R.id.progressbar1); - linear3 = findViewById(R.id.linear3); - linear5 = findViewById(R.id.linear5); - linear6 = findViewById(R.id.linear6); - hscroll1 = findViewById(R.id.hscroll1); - image_menu = findViewById(R.id.image_menu); - linear16 = findViewById(R.id.linear16); - image_favs = findViewById(R.id.image_favs); - image_comment = findViewById(R.id.image_comment); - image_repeat = findViewById(R.id.image_repeat); - image_nightcore = findViewById(R.id.image_nightcore); - image_download = findViewById(R.id.image_download); - image_lyrics = findViewById(R.id.image_lyrics); - image_share = findViewById(R.id.image_share); - linear7 = findViewById(R.id.linear7); - linear8 = findViewById(R.id.linear8); - seekbar1 = findViewById(R.id.seekbar1); - linear9 = findViewById(R.id.linear9); - linear12 = findViewById(R.id.linear12); - linear15 = findViewById(R.id.linear15); - image_album = findViewById(R.id.image_album); - linear14 = findViewById(R.id.linear14); - linear13 = findViewById(R.id.linear13); - text_title = findViewById(R.id.text_title); - text_artist = findViewById(R.id.text_artist); - text_current = findViewById(R.id.text_current); - linear10 = findViewById(R.id.linear10); - linear11 = findViewById(R.id.linear11); - text_duration = findViewById(R.id.text_duration); - image_prev = findViewById(R.id.image_prev); - image_play = findViewById(R.id.image_play); - image_next = findViewById(R.id.image_next); - _drawer_linear1 = _nav_view.findViewById(R.id.linear1); - _drawer_vscroll1 = _nav_view.findViewById(R.id.vscroll1); - _drawer_linear10 = _nav_view.findViewById(R.id.linear10); - _drawer_linear_usr = _nav_view.findViewById(R.id.linear_usr); - _drawer_linear2 = _nav_view.findViewById(R.id.linear2); - _drawer_linear6 = _nav_view.findViewById(R.id.linear6); - _drawer_linear_upload = _nav_view.findViewById(R.id.linear_upload); - _drawer_linear7 = _nav_view.findViewById(R.id.linear7); - _drawer_linear_theme = _nav_view.findViewById(R.id.linear_theme); - _drawer_linear_themesstr = _nav_view.findViewById(R.id.linear_themesstr); - _drawer_linear8 = _nav_view.findViewById(R.id.linear8); - _drawer_linear_info = _nav_view.findViewById(R.id.linear_info); - _drawer_linear_discord = _nav_view.findViewById(R.id.linear_discord); - _drawer_linear_settings = _nav_view.findViewById(R.id.linear_settings); - _drawer_linear9 = _nav_view.findViewById(R.id.linear9); - _drawer_linear_daedit = _nav_view.findViewById(R.id.linear_daedit); - _drawer_linear_logcat = _nav_view.findViewById(R.id.linear_logcat); - _drawer_imageview_tm = _nav_view.findViewById(R.id.imageview_tm); - _drawer_text_zryte = _nav_view.findViewById(R.id.text_zryte); - _drawer_text_zene = _nav_view.findViewById(R.id.text_zene); - _drawer_imageview_upload = _nav_view.findViewById(R.id.imageview_upload); - _drawer_text_upload = _nav_view.findViewById(R.id.text_upload); - _drawer_imageview_theme = _nav_view.findViewById(R.id.imageview_theme); - _drawer_text_theme = _nav_view.findViewById(R.id.text_theme); - _drawer_imageview_themesstr = _nav_view.findViewById(R.id.imageview_themesstr); - _drawer_text_themesstr = _nav_view.findViewById(R.id.text_themesstr); - _drawer_imageview_info = _nav_view.findViewById(R.id.imageview_info); - _drawer_text_info = _nav_view.findViewById(R.id.text_info); - _drawer_imageview_discord = _nav_view.findViewById(R.id.imageview_discord); - _drawer_text_discord = _nav_view.findViewById(R.id.text_discord); - _drawer_imageview_settings = _nav_view.findViewById(R.id.imageview_settings); - _drawer_text_settings = _nav_view.findViewById(R.id.text_settings); - _drawer_imageview_daedit = _nav_view.findViewById(R.id.imageview_daedit); - _drawer_text_daedit = _nav_view.findViewById(R.id.text_daedit); - _drawer_imageview_logcat = _nav_view.findViewById(R.id.imageview_logcat); - _drawer_text_logcat = _nav_view.findViewById(R.id.text_logcat); - _drawer_image_user = _nav_view.findViewById(R.id.image_user); - _drawer_linear_usr2 = _nav_view.findViewById(R.id.linear_usr2); - _drawer_text_user = _nav_view.findViewById(R.id.text_user); - _drawer_text_email = _nav_view.findViewById(R.id.text_email); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - d = new AlertDialog.Builder(this); - zz = new ZryteZeneAdaptor(this); - Intent siop = new Intent(getApplicationContext(), ZryteZenePlay.class); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - startForegroundService(siop); - } else { - startService(siop); - } - - image_drawer.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isPlaylist) { - isPlaylist = false; - childkey.clear(); - upload_list.clear(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setVisibility(View.GONE); - listview2.setVisibility(View.VISIBLE); - text_playlist.setVisibility(View.GONE); - text_zryte.setVisibility(View.VISIBLE); - text_zene.setVisibility(View.VISIBLE); - image_search.setVisibility(View.VISIBLE); - image_user.setVisibility(View.VISIBLE); - image_drawer.setImageResource(R.drawable.ic_menu); - x_tab.setVisibility(View.VISIBLE); - } else { - if (isSearching) { - isSearching = false; - x_tab.setVisibility(View.VISIBLE); - edittext_search.setVisibility(View.GONE); - text_zryte.setVisibility(View.VISIBLE); - text_zene.setVisibility(View.VISIBLE); - image_search.setVisibility(View.VISIBLE); - image_user.setVisibility(View.VISIBLE); - image_drawer.setImageResource(R.drawable.ic_menu); - _setMenu(tabsPos); - _abandonFocus(); - } else { - if (_drawer.isDrawerOpen(GravityCompat.START)) { - _drawer.closeDrawer(GravityCompat.START); - } else { - _drawer.openDrawer(GravityCompat.START); - } - } - } - } - }); - - edittext_search.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - final String _charSeq = _param1.toString(); - childkey.clear(); - upload_list.clear(); - double _tmpNum = 0; - for (int _repeat13 = 0; _repeat13 < oldListmap.size(); _repeat13++) { - if (usrname_list.contains(oldListmap.get((int) _tmpNum).get("uid").toString())) { - if (oldListmap.get((int) _tmpNum).get("name").toString().toLowerCase().contains(_charSeq.toLowerCase().trim()) || (profile_map.get(usrname_list.indexOf(oldListmap.get((int) _tmpNum).get("uid").toString())).get("username").toString().toLowerCase().contains(_charSeq.toLowerCase().trim()) || _charSeq.trim().equals(""))) { - childkey.add(0, oldChildKey.get((int) (_tmpNum))); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get((int) _tmpNum); - upload_list.add(0, _item); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } else { - if ((_tmpNum == (oldListmap.size() - 1)) && (upload_list.size() == 0)) { - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - } - } else { - if (oldListmap.get((int) _tmpNum).get("name").toString().toLowerCase().contains(_charSeq.toLowerCase().trim()) || (oldListmap.get((int) _tmpNum).get("uid").toString().toLowerCase().contains(_charSeq.toLowerCase().trim()) || _charSeq.trim().equals(""))) { - childkey.add(0, oldChildKey.get((int) (_tmpNum))); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get((int) _tmpNum); - upload_list.add(0, _item); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } else { - if ((_tmpNum == (oldListmap.size() - 1)) && (upload_list.size() == 0)) { - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - } - } - _tmpNum++; - } - } - - @Override - public void beforeTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - - } - - @Override - public void afterTextChanged(Editable _param1) { - - } - }); - - image_search.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - isSearching = true; - listview2.setVisibility(View.GONE); - listview1.setVisibility(View.VISIBLE); - x_tab.setVisibility(View.GONE); - text_zryte.setVisibility(View.GONE); - text_zene.setVisibility(View.GONE); - image_search.setVisibility(View.GONE); - image_user.setVisibility(View.GONE); - edittext_search.setVisibility(View.VISIBLE); - image_drawer.setImageResource(R.drawable.ic_arrow_back_white); - edittext_search.setText(""); - edittext_search.requestFocus(); - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(edittext_search, android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT); - childkey.clear(); - upload_list.clear(); - double _tmpNum = 0; - for (int _repeat27 = 0; _repeat27 < oldListmap.size(); _repeat27++) { - childkey.add(0, oldChildKey.get((int) (_tmpNum))); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get((int) _tmpNum); - upload_list.add(0, _item); - } - int _index = listview1.getFirstVisiblePosition(); - View _viewl = listview1.getChildAt(0); - int _top = (_viewl == null) ? 0 : _viewl.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - _tmpNum++; - } - } - }); - - image_user.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), ProfileActivity.class); - intent.putExtra("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - startActivity(intent); - } - }); - - image_menu.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (openNum == 2) { - openNum = 1; - obj.setTarget(linear2); - obj.setPropertyName("translationY"); - obj.setFloatValues(SketchwareUtil.getDip(getApplicationContext(), -200), SketchwareUtil.getDip(getApplicationContext(), -50)); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - obj2.setTarget(image_menu); - obj2.setPropertyName("rotation"); - obj2.setFloatValues((float) (0), (float) (180)); - obj2.setInterpolator(new DecelerateInterpolator()); - obj2.setDuration(500); - obj2.start(); - obj3.setTarget(linear7); - obj3.setPropertyName("alpha"); - obj3.setFloatValues((float) (1), (float) (0)); - obj3.setInterpolator(new DecelerateInterpolator()); - obj3.setDuration(500); - obj3.start(); - } else { - openNum = 2; - obj.setTarget(linear2); - obj.setPropertyName("translationY"); - obj.setFloatValues(SketchwareUtil.getDip(getApplicationContext(), -50), SketchwareUtil.getDip(getApplicationContext(), -200)); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - obj2.setTarget(image_menu); - obj2.setPropertyName("rotation"); - obj2.setFloatValues((float) (180), (float) (0)); - obj2.setInterpolator(new DecelerateInterpolator()); - obj2.setDuration(500); - obj2.start(); - obj3.setTarget(linear7); - obj3.setPropertyName("alpha"); - obj3.setFloatValues((float) (0), (float) (1)); - obj3.setInterpolator(new DecelerateInterpolator()); - obj3.setDuration(500); - obj3.start(); - } - } - }); - - image_favs.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (likeChild.contains(currentlyPlaying.concat(FirebaseAuth.getInstance().getCurrentUser().getUid()))) { - fb_likes.child(currentlyPlaying.concat(FirebaseAuth.getInstance().getCurrentUser().getUid())).removeValue(); - } else { - upload_map = new HashMap<>(); - upload_map.put("key", currentlyPlaying); - upload_map.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - fb_likes.child(currentlyPlaying.concat(FirebaseAuth.getInstance().getCurrentUser().getUid())).updateChildren(upload_map); - } - } - }); - - image_comment.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), MessageActivity.class); - intent.putExtra("key", currentlyPlaying); - startActivity(intent); - } - }); - - image_repeat.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (data.getString("fvsAsc", "").equals("0")) { - data.edit().putString("fvsAsc", "1").commit(); - image_repeat.setAlpha((float) (1.0d)); - } else { - if (data.getString("fvsAsc", "").equals("1")) { - data.edit().putString("fvsAsc", "2").commit(); - image_repeat.setImageResource(R.drawable.ic_repeat_one_white); - } else { - if (data.getString("fvsAsc", "").equals("2")) { - data.edit().putString("fvsAsc", "3").commit(); - image_repeat.setImageResource(R.drawable.ic_shuffle_white); - } else { - data.edit().putString("fvsAsc", "0").commit(); - image_repeat.setAlpha((float) (0.5d)); - image_repeat.setImageResource(R.drawable.ic_repeat_white); - } - } - } - zz.requestAction("update-sp","loop"); - } - }); - - image_nightcore.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (data.getString("nightcore", "").equals("1")) { - data.edit().putString("nightcore", "0").commit(); - image_nightcore.setAlpha((float) (0.5d)); - //tmservice._setNightcore(1.00f); - } else { - data.edit().putString("nightcore", "1").commit(); - image_nightcore.setAlpha((float) (1.0d)); - float _tmpFloat = 1.10f + ((float) Double.parseDouble(data.getString("nightcoreSpeed", "")) * 0.05f); - //tmservice._setNightcore(_tmpFloat); - } - } else { - data.edit().putString("nightcore", "0").commit(); - image_nightcore.setAlpha((float) (0.5d)); - _customSnack("Android Lollipop or lower doesn't support nightcore feature!", 2); - } - } - }); - - image_download.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - d.setCancelable(false); - d.setTitle("Download"); - d.setMessage("Do you want to save this music to your storage?"); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _downloadFile(currentlyMap.get(currentlyChild.indexOf(currentlyPlaying)).get("url").toString(), FileUtil.getPublicDir(Environment.DIRECTORY_MUSIC)); - _customSnack("Downloading...", 0); - _resetDialog(); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } - }); - - image_lyrics.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (text_title.getText().toString().contains("-")) { - intent.setClass(getApplicationContext(), LyricsActivity.class); - intent.putExtra("musicName", text_title.getText().toString()); - startActivity(intent); - } else { - intent.setClass(getApplicationContext(), LyricsActivity.class); - intent.putExtra("musicName", text_artist.getText().toString().concat(" - ".concat(text_title.getText().toString()))); - startActivity(intent); - } - } - }); - - image_share.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (currentlyPlaying.length() > 0) { - i2.setData(Uri.parse("https://zrytezene.xyz/music.html?play=".concat(currentlyPlaying))); - i2.setAction(Intent.ACTION_VIEW); - startActivity(i2); - } - } - }); - - seekbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _param2, boolean _param3) { - final int _progressValue = _param2; - text_current.setText(new DecimalFormat("00").format(_progressValue / 60).concat(":".concat(new DecimalFormat("00").format(_progressValue % 60)))); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - } - - @Override - public void onStopTrackingTouch(SeekBar _param2) { - zz.requestAction("seek", seekbar1.getProgress() * 1000); - } - }); - - image_prev.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (data.getString("fvsAsc", "").equals("3")) { - _play(currentlyChild.get(SketchwareUtil.getRandom(0, currentlyMap.size() - 1))); - } else { - if (currentlyChild.indexOf(currentlyPlaying) > 0) { - _play(currentlyChild.get(currentlyChild.indexOf(currentlyPlaying) - 1)); - } else { - _play(currentlyChild.get(currentlyMap.size() - 1)); - } - } - } - }); - - image_play.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (zz.isPlaying()) { - zz.requestAction("pause"); - } else if (zz.isInitialized()) { - zz.requestAction("resume"); - } - } - }); - - image_next.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (data.getString("fvsAsc", "").equals("3")) { - _play(currentlyChild.get(SketchwareUtil.getRandom(0, currentlyMap.size() - 1))); - } else { - if (currentlyMap.size() > (currentlyChild.indexOf(currentlyPlaying) + 1)) { - _play(currentlyChild.get(currentlyChild.indexOf(currentlyPlaying) + 1)); - } else { - _play(currentlyChild.get(0)); - } - } - } - }); - - _upload_text_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - linear_data.setVisibility(View.GONE); - listview1.setVisibility(View.VISIBLE); - x_tab.setEnabled(true); - { - LinearLayout _tabStrip = ((LinearLayout) x_tab.getChildAt(0)); - _tabStrip.setEnabled(true); - for (int i = 0; i < _tabStrip.getChildCount(); i++) { - _tabStrip.getChildAt(i).setClickable(true); - } - } - oldChildKey.add(_childKey); - oldListmap.add(_childValue); - if (isSearching) { - if (_childValue.get("name").toString().toLowerCase().contains(edittext_search.getText().toString().toLowerCase().trim()) || (_childValue.get("uid").toString().toLowerCase().contains(edittext_search.getText().toString().toLowerCase().trim()) || edittext_search.getText().toString().toLowerCase().trim().equals(""))) { - childkey.add(0, _childKey); - upload_list.add(0, _childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - } else { - if (tabsPos == 0) { - childkey.add(0, _childKey); - upload_list.add(0, _childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - if (tabsPos == 2) { - double _tmpNum = 0; - boolean _tmp_bool = false; - for (int _repeat57 = 0; _repeat57 < upload_list.size(); _repeat57++) { - if ((Double.parseDouble(_childValue.get("view").toString()) > Double.parseDouble(upload_list.get((int) _tmpNum).get("view").toString())) || (Double.parseDouble(_childValue.get("view").toString()) == Double.parseDouble(upload_list.get((int) _tmpNum).get("view").toString()))) { - if (!_tmp_bool) { - childkey.add((int) (_tmpNum), _childKey); - upload_list.add((int) _tmpNum, _childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - _tmp_bool = true; - } - } - _tmpNum++; - } - if (!_tmp_bool) { - childkey.add(_childKey); - upload_list.add(_childValue); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - } - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - upload_text.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - oldListmap = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - oldListmap.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - if (childkey.contains(_childKey)) { - upload_list.get(childkey.indexOf(_childKey)).put("url", _childValue.get("url").toString()); - upload_list.get(childkey.indexOf(_childKey)).put("name", _childValue.get("name").toString()); - upload_list.get(childkey.indexOf(_childKey)).put("view", _childValue.get("view").toString()); - upload_list.get(childkey.indexOf(_childKey)).put("uid", _childValue.get("uid").toString()); - if (_childValue.containsKey("img")) { - upload_list.get(childkey.indexOf(_childKey)).put("img", _childValue.get("img").toString()); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - if (currentlyChild.contains(_childKey)) { - currentlyMap.get(currentlyChild.indexOf(_childKey)).put("url", _childValue.get("url").toString()); - currentlyMap.get(currentlyChild.indexOf(_childKey)).put("name", _childValue.get("name").toString()); - currentlyMap.get(currentlyChild.indexOf(_childKey)).put("view", _childValue.get("view").toString()); - currentlyMap.get(currentlyChild.indexOf(_childKey)).put("uid", _childValue.get("uid").toString()); - if (_childValue.containsKey("img")) { - currentlyMap.get(currentlyChild.indexOf(_childKey)).put("img", _childValue.get("img").toString()); - } - } - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (currentlyPlaying.equals(_childKey)) { - currentlyPlaying = ""; - openNum = 0; - obj.setTarget(linear2); - obj.setPropertyName("translationX"); - obj.setFloatValues((float) (0), (float) (SketchwareUtil.getDisplayWidthPixels(getApplicationContext()) + SketchwareUtil.getDisplayHeightPixels(getApplicationContext()))); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - _customNav(theme_map.get(0).get("colorBackground").toString()); - //tmservice._removeFocus(); - //tmservice._resetMp(); - currentlyMap.clear(); - currentlyChild.clear(); - } - oldListmap.remove(oldChildKey.indexOf(_childKey)); - oldChildKey.remove(oldChildKey.indexOf(_childKey)); - if (childkey.contains(_childKey)) { - upload_list.remove(childkey.indexOf(_childKey)); - childkey.remove(childkey.indexOf(_childKey)); - } - //if (!tmservice._isMpNull() && currentlyChild != null) { - //if (currentlyChild.contains(_childKey)) { - //currentlyMap.remove(currentlyChild.indexOf(_childKey)); - //currentlyChild.remove(currentlyChild.indexOf(_childKey)); - //} - //} - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - upload_text.addChildEventListener(_upload_text_child_listener); - - _profile_admins_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - adminsList.add(_childKey); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - isAdmin = true; - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile_admins.addChildEventListener(_profile_admins_child_listener); - - _comments_db_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - commentsChildKey.add(_childKey); - commentsTmp.add(_childValue); - if (commentsMap.containsKey(_childValue.get("key").toString())) { - commentsMap.put(_childValue.get("key").toString(), String.valueOf((long) (Double.parseDouble(commentsMap.get(_childValue.get("key").toString()).toString()) + 1))); - } else { - commentsMap.put(_childValue.get("key").toString(), "1"); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - commentsTmp.remove(commentsChildKey.indexOf(_childKey)); - commentsChildKey.remove(commentsChildKey.indexOf(_childKey)); - if (Double.parseDouble(commentsMap.get(_childValue.get("key").toString()).toString()) > 1) { - commentsMap.put(_childValue.get("key").toString(), String.valueOf((long) (Double.parseDouble(commentsMap.get(_childValue.get("key").toString()).toString()) - 1))); - } else { - commentsMap.remove(_childValue.get("key").toString()); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - comments_db.addChildEventListener(_comments_db_child_listener); - - _profile_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - usrname_list.add(_childKey); - profile_map.add(_childValue); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - _drawer_text_email.setText(FirebaseAuth.getInstance().getCurrentUser().getEmail()); - _drawer_text_user.setText(_childValue.get("username").toString()); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - profile.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - profile_map = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - profile_map.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - _drawer_text_user.setText(_childValue.get("username").toString()); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile.addChildEventListener(_profile_child_listener); - - _fb_likes_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - likeChild.add(_childKey); - like_tmp.add(_childValue); - if (likes_map.containsKey(_childValue.get("key").toString())) { - likes_map.put(_childValue.get("key").toString(), String.valueOf((long) (Double.parseDouble(likes_map.get(_childValue.get("key").toString()).toString()) + 1))); - } else { - likes_map.put(_childValue.get("key").toString(), "1"); - } - _refreshLikes(); - if ((tabsPos == 1) && (_childValue.get("uid").toString().equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) && (oldChildKey.contains(_childValue.get("key").toString()) && !isSearching))) { - childkey.add(0, _childValue.get("key").toString()); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get(oldChildKey.indexOf(_childValue.get("key"))); - upload_list.add(0, _item); - } - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - like_tmp.remove(likeChild.indexOf(_childKey)); - likeChild.remove(likeChild.indexOf(_childKey)); - if (Double.parseDouble(likes_map.get(_childValue.get("key").toString()).toString()) > 1) { - likes_map.put(_childValue.get("key").toString(), String.valueOf((long) (Double.parseDouble(likes_map.get(_childValue.get("key").toString()).toString()) - 1))); - } else { - likes_map.remove(_childValue.get("key").toString()); - } - _refreshLikes(); - if ((tabsPos == 1) && (childkey.contains(_childValue.get("key").toString()) && !isSearching)) { - upload_list.remove(childkey.indexOf(_childValue.get("key").toString())); - childkey.remove(childkey.indexOf(_childValue.get("key").toString())); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - fb_likes.addChildEventListener(_fb_likes_child_listener); - - _prof_img_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - image_user.clearColorFilter(); - _drawer_image_user.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(image_user) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - image_user.setImageDrawable(circularBitmapDrawable); - } - }); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(_drawer_image_user) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - _drawer_image_user.setImageDrawable(circularBitmapDrawable); - } - }); - hasPic = true; - } - img_maps.put(_childKey, _childValue.get("url").toString()); - ((BaseAdapter) listview1.getAdapter()).notifyDataSetChanged(); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(image_user) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - image_user.setImageDrawable(circularBitmapDrawable); - } - }); - Glide.with(getApplicationContext()).asBitmap().load(_childValue.get("url").toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(_drawer_image_user) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - _drawer_image_user.setImageDrawable(circularBitmapDrawable); - } - }); - } - img_maps.put(_childKey, _childValue.get("url").toString()); - ((BaseAdapter) listview1.getAdapter()).notifyDataSetChanged(); - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - prof_img.addChildEventListener(_prof_img_child_listener); - - _check_quota_upload_progress_listener = new OnProgressListener() { - @Override - public void onProgress(UploadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _check_quota_download_progress_listener = new OnProgressListener() { - @Override - public void onProgress(FileDownloadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _check_quota_upload_success_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final String _downloadUrl = _param1.getResult().toString(); - - } - }; - - _check_quota_download_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot _param1) { - final long _totalByteCount = _param1.getTotalByteCount(); - if (FileUtil.isExistFile(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tm-testfile"))) { - FileUtil.deleteFile(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tm-testfile")); - } - } - }; - - _check_quota_delete_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(Object _param1) { - - } - }; - - _check_quota_failure_listener = new OnFailureListener() { - @Override - public void onFailure(Exception _param1) { - final String _message = _param1.getMessage(); - if (FileUtil.isExistFile(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tm-testfile"))) { - FileUtil.deleteFile(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tm-testfile")); - } - d.setCancelable(false); - d.setTitle("Daily quota is exhausted!"); - d.setMessage("Sorry for the inconveniences, but the daily quota limit is reached and you can't read, edit, or upload anything during this time until tomorrow at 07:00 UTC."); - d.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.setNegativeButton("Read error message", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - _customSnack(_message, 2); - } - }); - d.create().show(); - } - }; - - _upload_storage_upload_progress_listener = new OnProgressListener() { - @Override - public void onProgress(UploadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _upload_storage_download_progress_listener = new OnProgressListener() { - @Override - public void onProgress(FileDownloadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _upload_storage_upload_success_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final String _downloadUrl = _param1.getResult().toString(); - - } - }; - - _upload_storage_download_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot _param1) { - final long _totalByteCount = _param1.getTotalByteCount(); - - } - }; - - _upload_storage_delete_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(Object _param1) { - - } - }; - - _upload_storage_failure_listener = new OnFailureListener() { - @Override - public void onFailure(Exception _param1) { - final String _message = _param1.getMessage(); - _customSnack(_message, 2); - } - }; - - _music_image_upload_progress_listener = new OnProgressListener() { - @Override - public void onProgress(UploadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _music_image_download_progress_listener = new OnProgressListener() { - @Override - public void onProgress(FileDownloadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _music_image_upload_success_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final String _downloadUrl = _param1.getResult().toString(); - - } - }; - - _music_image_download_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot _param1) { - final long _totalByteCount = _param1.getTotalByteCount(); - - } - }; - - _music_image_delete_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(Object _param1) { - - } - }; - - _music_image_failure_listener = new OnFailureListener() { - @Override - public void onFailure(Exception _param1) { - final String _message = _param1.getMessage(); - _customSnack(_message, 2); - } - }; - - _drawer_linear1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - } - }); - - _drawer_linear_usr.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), ProfileActivity.class); - intent.putExtra("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - i2.setData(Uri.parse("https://zrytezene.xyz")); - i2.setAction(Intent.ACTION_VIEW); - startActivity(i2); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_upload.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), UploadActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_theme.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), ThemesActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_themesstr.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), ThemesstrActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_info.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), AboutActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_discord.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - i2.setData(Uri.parse("https://discord.gg/ERpx6dv")); - i2.setAction(Intent.ACTION_VIEW); - startActivity(i2); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_settings.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), SettingsActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_daedit.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), DaeditActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _drawer_linear_logcat.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), LogcatActivity.class); - startActivity(intent); - _drawer.closeDrawer(GravityCompat.START); - } - }); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - getSupportActionBar().hide(); - hscroll1.setVerticalScrollBarEnabled(false); - hscroll1.setHorizontalScrollBarEnabled(false); - setVolumeControlStream(AudioManager.STREAM_MUSIC); - - x_tab = new com.google.android.material.tabs.TabLayout(StreamerActivity.this); - x_tab.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)); - x_tab.setTabMode(TabLayout.MODE_SCROLLABLE); - x_tab.setTabGravity(TabLayout.GRAVITY_CENTER); - x_tab.setSelectedTabIndicatorHeight(6); - x_tab.addTab(x_tab.newTab().setText("Library")); - x_tab.getChildAt(0).setPadding(70, 0, 70, 0); - x_tab.addTab(x_tab.newTab().setText("My Favs")); - x_tab.addTab(x_tab.newTab().setText("Most Played")); - x_tab.addTab(x_tab.newTab().setText("My Playlists")); - - linear_title.removeView(linear_title_shdw); - linear_title.addView(x_tab); - linear_title.addView(linear_title_shdw); - - x_tab.addOnTabSelectedListener(new com.google.android.material.tabs.TabLayout.OnTabSelectedListener() { - - @Override - public void onTabSelected(com.google.android.material.tabs.TabLayout.Tab tab) { - _setMenu(tab.getPosition()); - } - - @Override - public void onTabUnselected(com.google.android.material.tabs.TabLayout.Tab tab) { - } - - @Override - public void onTabReselected(com.google.android.material.tabs.TabLayout.Tab tab) { - } - - }); - - linear2.setOnTouchListener(new View.OnTouchListener() { - @Override - public boolean onTouch(View p1, MotionEvent p2) { - switch (p2.getAction()) { - case MotionEvent.ACTION_DOWN: - _f = p2.getX(); - break; - case MotionEvent.ACTION_UP: - _t = p2.getX(); - if (((_f - _t) < -150)) { - currentlyPlaying = ""; - openNum = 0; - obj.setTarget(linear2); - obj.setPropertyName("translationX"); - obj.setFloatValues((float) (0), (float) (SketchwareUtil.getDisplayWidthPixels(getApplicationContext()) + SketchwareUtil.getDisplayHeightPixels(getApplicationContext()))); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - _customNav(theme_map.get(0).get("colorBackground").toString()); - //tmservice._removeFocus(); - //tmservice._resetMp(); - currentlyMap.clear(); - currentlyChild.clear(); - } - break; - } - return true; - } - }); - fb_likes.removeEventListener(_fb_likes_child_listener); - dialog_list.add("Profile"); - dialog_list.add("Delete"); - dialog_list.add("Comments"); - dialog_list.add("Add to my playlist"); - dialog_list.add("Cancel"); - playlistMap = new Gson().fromJson(data.getString("playlist", ""), new TypeToken>>() { - }.getType()); - for (int _repeat142 = 0; _repeat142 < playlistMap.size(); _repeat142++) { - playlistString.add(playlistMap.get(playlistString.size()).get("name").toString()); - } - playlistString.add("Add a playlist"); - Listview2Adapter = new ArrayAdapter(StreamerActivity.this, R.layout.playlist_clickable, R.id.text_playlist, playlistString) { - @Override - public View getView(int _position, View _convertView, ViewGroup _parent) { - View _view = super.getView(_position, _convertView, _parent); - ((TextView) _view.findViewById(R.id.text_playlist)).setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - if (_position == playlistString.size() - 1) { - ((ImageView) _view.findViewById(R.id.image_playlist)).setImageResource(R.drawable.ic_add_white); - } else { - ((ImageView) _view.findViewById(R.id.image_playlist)).setImageResource(R.drawable.ic_album_white); - } - _view.findViewById(R.id.linear_playlist).setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _view.findViewById(R.id.linear_playlist).setClickable(true); - ((TextView) _view.findViewById(R.id.text_playlist)).setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - ((ImageView) _view.findViewById(R.id.image_playlist)).setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString()), PorterDuff.Mode.MULTIPLY); - final double _pos = _position; - _view.findViewById(R.id.linear_playlist).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _addGrid(_pos); - } - }); - _view.findViewById(R.id.linear_playlist).setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _view) { - _delGrid(_pos); - return true; - } - }); - return _view; - } - - }; - listview2 = new GridView(StreamerActivity.this); - - listview2.setLayoutParams(new GridView.LayoutParams(GridLayout.LayoutParams.MATCH_PARENT, GridLayout.LayoutParams.WRAP_CONTENT)); - listview2.setNumColumns(GridView.AUTO_FIT); - listview2.setVerticalSpacing(2); - listview2.setHorizontalSpacing(2); - listview2.setColumnWidth((int) SketchwareUtil.getDip(getApplicationContext(), 118)); - listview2.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); - linear1.addView(listview2); - listview2.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int _pos, long id) { - } - }); - - listview2.setAdapter(Listview2Adapter); - _loadTheme(); - _bindSvc(); - try { - android.content.pm.PackageInfo packageInfo = StreamerActivity.this.getPackageManager().getPackageInfo(getPackageName(), 0); - } catch (Exception _e) { - } - text_title.setEllipsize(TextUtils.TruncateAt.MARQUEE); - text_title.setMarqueeRepeatLimit(-1); - text_title.setSingleLine(true); - text_title.setSelected(true); - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.TRANSPARENT}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - seekbar1.setBackground(ripdrb); - linear2.setTranslationY(SketchwareUtil.getDip(getApplicationContext(), 500)); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setVisibility(View.GONE); - listview2.setVisibility(View.GONE); - x_tab.setEnabled(false); - { - LinearLayout _tabStrip = ((LinearLayout) x_tab.getChildAt(0)); - _tabStrip.setEnabled(false); - for (int i = 0; i < _tabStrip.getChildCount(); i++) { - _tabStrip.getChildAt(i).setClickable(false); - } - } - text_playlist.setVisibility(View.GONE); - edittext_search.setVisibility(View.GONE); - Typeface tsans = Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"); - Typeface tbold = Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"); - text_zryte.setTypeface(tsans, 0); - text_zene.setTypeface(tbold, 0); - text_playlist.setTypeface(tsans, 0); - text_data.setTypeface(tsans, 0); - text_title.setTypeface(tsans, 0); - text_artist.setTypeface(tsans, 0); - text_current.setTypeface(tsans, 0); - text_duration.setTypeface(tsans, 0); - edittext_search.setTypeface(tsans, 0); - _drawer_text_zryte.setTypeface(tsans, 0); - _drawer_text_zene.setTypeface(tbold, 0); - _drawer_text_user.setTypeface(tsans, 0); - _drawer_text_email.setTypeface(tsans, 0); - _drawer_text_upload.setTypeface(tsans, 0); - _drawer_text_theme.setTypeface(tsans, 0); - _drawer_text_themesstr.setTypeface(tsans, 0); - _drawer_text_info.setTypeface(tsans, 0); - _drawer_text_logcat.setTypeface(tsans, 0); - _drawer_text_discord.setTypeface(tsans, 0); - _drawer_text_daedit.setTypeface(tsans, 0); - _drawer_text_settings.setTypeface(tsans, 0); - if (data.getString("taptarget", "").equals("1")) { - //_NewTapTarget(image_user, "Account", "Click here or by clicking account information on the drawer for accessing your account info & settings", "#2196F3"); - } else { - if (!data.getString("taptarget", "").equals("2")) { - //_NewTapTarget(image_drawer, "Menu", "Click here for accessing some extra menu", "#2196F3"); - } - } - if (data.getString("nightcore", "").equals("1")) { - image_nightcore.setAlpha((float) (1.0d)); - } else { - image_nightcore.setAlpha((float) (0.5d)); - } - if (data.getString("fvsAsc", "").equals("0")) { - image_repeat.setAlpha((float) (0.5d)); - image_repeat.setImageResource(R.drawable.ic_repeat_white); - } else { - if (data.getString("fvsAsc", "").equals("1")) { - image_repeat.setAlpha((float) (1.0d)); - image_repeat.setImageResource(R.drawable.ic_repeat_white); - } else { - if (data.getString("fvsAsc", "").equals("2")) { - image_repeat.setAlpha((float) (1.0d)); - image_repeat.setImageResource(R.drawable.ic_repeat_one_white); - } else { - image_repeat.setAlpha((float) (1.0d)); - image_repeat.setImageResource(R.drawable.ic_shuffle_white); - } - } - } - FirebaseStorage.getInstance().getReferenceFromUrl("https://firebasestorage.googleapis.com/v0/b/teammusic-tw.appspot.com/o/tm-testfile?alt=media&token=ec852b8b-438c-457a-887d-b289968971ec").getFile(new File(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tm-testfile"))).addOnSuccessListener(_check_quota_download_success_listener).addOnFailureListener(_check_quota_failure_listener).addOnProgressListener(_check_quota_download_progress_listener); - IntentFilter filr = new IntentFilter(ZryteZenePlay.ACTION_UPDATE); - registerReceiver(listenerReceiver, filr); - zz.requestAction("request-media"); - } - - private BroadcastReceiver listenerReceiver = new BroadcastReceiver() { - @Override - public void onReceive(Context context, Intent intent) { - if (intent != null && intent.getAction() != null) { - if (intent.getAction().equals(ZryteZenePlay.ACTION_UPDATE)) { - String m = intent.getStringExtra("update"); - if (m.equals("on-prepared")) { - _CoreProgressLoading(false); - zz.setPlaying(true); - zz.setCurrentDuration(0); - zz.setDuration(intent.getIntExtra("data",0)/1000); - seekbar1.setProgress(0); - seekbar1.setMax(zz.getDuration()); - _showPlayer(); - } else if (m.equals("on-reqmedia")) { - } else if (m.equals("on-tick")) { - zz.setCurrentDuration(intent.getIntExtra("data",0)); - seekbar1.setProgress(zz.getCurrentDuration()/1000); - } else if (m.equals("on-completion")) { - zz.setPlaying(false); - } else if (m.equals("on-error")) { - zz.addError(intent.getStringExtra("data")); - } else if (m.equals("on-seekerror")) { - } else if (m.equals("on-initialized")) { - } else if (m.equals("on-bufferupdate")) { - zz.setBufferingUpdate(intent.getIntExtra("data",0)); - } else if (m.equals("request-play")) { - } else if (m.equals("request-pause")) { - zz.setPlaying(false); - } else if (m.equals("request-resume")) { - zz.setPlaying(true); - } else if (m.equals("request-stop")) { - zz.setPlaying(false); - } else if (m.equals("request-seek")) { - zz.setCurrentDuration(intent.getIntExtra("data",0)/1000); - } else if (m.equals("request-restart")) { - zz.setCurrentDuration(0); - } else if (m.equals("request-reset")) { - } - } - } - } - }; - - @Override - public void onBackPressed() { - if (_drawer.isDrawerOpen(GravityCompat.START)) { - _drawer.closeDrawer(GravityCompat.START); - } else { - if (isPlaylist) { - isPlaylist = false; - childkey.clear(); - upload_list.clear(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setVisibility(View.GONE); - listview2.setVisibility(View.VISIBLE); - text_playlist.setVisibility(View.GONE); - text_zryte.setVisibility(View.VISIBLE); - text_zene.setVisibility(View.VISIBLE); - image_search.setVisibility(View.VISIBLE); - image_user.setVisibility(View.VISIBLE); - image_drawer.setImageResource(R.drawable.ic_menu); - x_tab.setVisibility(View.VISIBLE); - } else { - if (isSearching) { - isSearching = false; - x_tab.setVisibility(View.VISIBLE); - edittext_search.setVisibility(View.GONE); - text_zryte.setVisibility(View.VISIBLE); - text_zene.setVisibility(View.VISIBLE); - image_search.setVisibility(View.VISIBLE); - image_user.setVisibility(View.VISIBLE); - image_drawer.setImageResource(R.drawable.ic_menu); - _setMenu(tabsPos); - _abandonFocus(); - } else { - finish(); - } - } - } - } - - @Override - public void onStart() { - super.onStart(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(0); - } - _loadTheme(); - if (!(openNum == 0)) { - _customNav(theme_map.get(0).get("colorPrimary").toString()); - } - if (hasPic) { - image_user.clearColorFilter(); - _drawer_image_user.clearColorFilter(); - } - /* - if (tmservice != null) { - if (!currentlyPlaying.equals("") && !tmservice._isMpNull()) { - if (currentlyMap.get(currentlyChild.indexOf(currentlyPlaying)).containsKey("img")) { - image_album.clearColorFilter(); - } - if (adminsList.contains(currentlyMap.get(currentlyChild.indexOf(currentlyPlaying)).get("uid").toString())) { - text_artist.setTextColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - } else { - text_artist.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryCardText").toString())); - } - } - } - ((BaseAdapter) listview1.getAdapter()).notifyDataSetChanged();*/ - } - - @Override - public void onResume() { - super.onResume(); - } - - @Override - public void onPause() { - super.onPause(); - } - - @Override - public void onStop() { - super.onStop(); - } - - @Override - public void onDestroy() { - super.onDestroy(); - //_unbindSvc(); - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private int getDominantColor(Bitmap bitmap) { - if (bitmap == null) { - return Color.TRANSPARENT; - } - int width = bitmap.getWidth(); - int height = bitmap.getHeight(); - int size = width * height; - int[] pixels = new int[size]; - bitmap.getPixels(pixels, 0, width, 0, 0, width, height); - int color; - int r = 0; - int g = 0; - int b = 0; - int a; - int count = 0; - for (int i = 0; i < pixels.length; i++) { - color = pixels[i]; - a = Color.alpha(color); - if (a > 0) { - r += Color.red(color); - g += Color.green(color); - b += Color.blue(color); - count++; - } - } - r /= count; - g /= count; - b /= count; - r = (r << 16) & 0x00FF0000; - g = (g << 8) & 0x0000FF00; - b = b & 0x000000FF; - color = 0xFF000000 | r | g | b; - return color; - } - - private boolean isDark(int color) { - return androidx.core.graphics.ColorUtils.calculateLuminance(color) < 0.5; - } - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - private void _Rounded(final double _kiri_atas, final double _kanan_atas, final double _kiri_bawah, final double _kanan_bawah, final String _warna, final View _view) { - Double atas_kiri = _kiri_atas; - Double atas_kanan = _kanan_atas; - Double bawah_kiri = _kiri_bawah; - Double bawah_kanan = _kanan_bawah; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{atas_kiri.floatValue(), atas_kiri.floatValue(), atas_kanan.floatValue(), atas_kanan.floatValue(), bawah_kiri.floatValue(), bawah_kiri.floatValue(), bawah_kanan.floatValue(), bawah_kanan.floatValue()}); - s.setColor(Color.parseColor(_warna)); - _view.setBackground(s); - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - } - _customNav(theme_map.get(0).get("colorBackground").toString()); - _Rounded(SketchwareUtil.getDip(getApplicationContext(), 5), 0, 0, 0, theme_map.get(0).get("colorButton").toString(), linear12); - _Rounded(SketchwareUtil.getDip(getApplicationContext(), (int) (7.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (7.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (7.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (7.5d)), theme_map.get(0).get("colorBackgroundCard").toString(), linear_title2); - _Rounded(SketchwareUtil.getDip(getApplicationContext(), 5), 0, 0, SketchwareUtil.getDip(getApplicationContext(), 5), theme_map.get(0).get("colorPrimaryCard").toString(), linear7); - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear7, 15); - _shadow(linear_title2, 10); - if (isDark(Color.parseColor(theme_map.get(0).get("colorBackground").toString()))) { - linear_title_shdw.setBackgroundColor(0xFF808080); - _drawer_linear6.setBackgroundColor(0xFF808080); - _drawer_linear7.setBackgroundColor(0xFF808080); - _drawer_linear8.setBackgroundColor(0xFF808080); - _drawer_linear9.setBackgroundColor(0xFF808080); - _drawer_linear10.setBackgroundColor(0xFF808080); - } else { - linear_title_shdw.setBackgroundColor(0xFFBDBDBD); - _drawer_linear6.setBackgroundColor(0xFFBDBDBD); - _drawer_linear7.setBackgroundColor(0xFFBDBDBD); - _drawer_linear8.setBackgroundColor(0xFFBDBDBD); - _drawer_linear9.setBackgroundColor(0xFFBDBDBD); - _drawer_linear10.setBackgroundColor(0xFFBDBDBD); - } - } else { - _shadow(linear7, 0); - _shadow(linear_title2, 0); - linear_title_shdw.setBackgroundColor(Color.TRANSPARENT); - _drawer_linear6.setBackgroundColor(Color.TRANSPARENT); - _drawer_linear7.setBackgroundColor(Color.TRANSPARENT); - _drawer_linear8.setBackgroundColor(Color.TRANSPARENT); - _drawer_linear9.setBackgroundColor(Color.TRANSPARENT); - _drawer_linear10.setBackgroundColor(Color.TRANSPARENT); - } - text_zryte.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - text_zene.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - text_playlist.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - edittext_search.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - x_tab.setSelectedTabIndicatorColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - x_tab.setTabTextColors(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString()), Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - - { - ViewGroup _vg = (ViewGroup) x_tab.getChildAt(0); - int _tabsCount = _vg.getChildCount(); - for (int j = 0; j < _tabsCount; j++) { - ViewGroup _vgTab = (ViewGroup) _vg.getChildAt(j); - int _tabChildsCount = _vgTab.getChildCount(); - for (int i = 0; i < _tabChildsCount; i++) { - View _tabViewChild = _vgTab.getChildAt(i); - if (_tabViewChild instanceof TextView) { - ((TextView) _tabViewChild).setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - ((TextView) _tabViewChild).setAllCaps(false); - } - } - } - } - image_prev.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryCardImage").toString()), PorterDuff.Mode.MULTIPLY); - image_play.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryCardImage").toString()), PorterDuff.Mode.MULTIPLY); - image_next.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryCardImage").toString()), PorterDuff.Mode.MULTIPLY); - text_title.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryCardText").toString())); - text_artist.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryCardText").toString())); - text_current.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryCardText").toString())); - text_duration.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryCardText").toString())); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_search); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_menu); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_prev); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_play); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_next); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_favs); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_comment); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_repeat); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_nightcore); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_download); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_lyrics); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_share); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_drawer); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_user); - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - image_search.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - image_favs.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_comment.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_repeat.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_nightcore.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_download.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_lyrics.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_share.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_menu.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - image_drawer.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - image_user.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundCardImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_linear_upload.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_upload.setClickable(true); - _drawer_linear_theme.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_theme.setClickable(true); - _drawer_linear_themesstr.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_themesstr.setClickable(true); - _drawer_linear_info.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_info.setClickable(true); - _drawer_linear_logcat.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_logcat.setClickable(true); - _drawer_linear_discord.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_discord.setClickable(true); - _drawer_linear_daedit.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_daedit.setClickable(true); - _drawer_linear_settings.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - _drawer_linear_settings.setClickable(true); - _drawer_image_user.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_upload.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_theme.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_themesstr.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_info.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_logcat.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_daedit.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - _drawer_imageview_settings.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - seekbar1.getProgressDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - - seekbar1.getThumb().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - _drawer_linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - _drawer_text_zryte.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_zene.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_user.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_email.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_upload.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_theme.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_themesstr.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_info.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_logcat.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_discord.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_daedit.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - _drawer_text_settings.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - text_data.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (!isDark(Color.parseColor(theme_map.get(0).get("colorBackground").toString()))) { - _BlackStatusBarIcons(); - } - progressbar1.getIndeterminateDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - edittext_search.setHintTextColor(Color.parseColor(theme_map.get(0).get("colorHint").toString())); - } - - private void _refreshLikes() { - //if (!tmservice._isMpNull()) { - if (likeChild.contains(currentlyPlaying.concat(FirebaseAuth.getInstance().getCurrentUser().getUid()))) { - image_favs.setImageResource(R.drawable.ic_favorite); - } else { - image_favs.setImageResource(R.drawable.ic_favorite_border); - } - //} - } - - private void _CoreProgressLoading(final boolean _ifShow) { - if (_ifShow) { - if (coreprog == null) { - coreprog = new ProgressDialog(this); - coreprog.setCancelable(false); - coreprog.setCanceledOnTouchOutside(false); - - coreprog.requestWindowFeature(Window.FEATURE_NO_TITLE); - coreprog.getWindow().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(Color.TRANSPARENT)); - - } - coreprog.setMessage(null); - coreprog.show(); - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _coreView = _inflater.inflate(R.layout.custom_dialog, null); - final ImageView imageview1 = _coreView.findViewById(R.id.imageview1); - com.bumptech.glide.Glide.with(getApplicationContext()).load(R.raw.partyblob).into(imageview1); - coreprog.setContentView(_coreView); - } else { - if (coreprog != null) { - coreprog.dismiss(); - } - } - } - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - private void _downloadFile(final String _url, final String _path) { - try { - String _fileName = URLUtil.guessFileName(_url, null, null); - java.io.File _filePath = new java.io.File(_path + "/" + _fileName); - DownloadManager.Request request = new DownloadManager.Request(Uri.parse(_url)); - request.setDescription(_url); - request.setTitle(_fileName); - request.allowScanningByMediaScanner(); - request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE); - request.setDestinationUri(Uri.fromFile(_filePath)); - final DownloadManager downloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE); - final long downloadID = downloadManager.enqueue(request); - } catch (Exception _error) { - _customSnack(_error.getMessage(), 2); - } - } - - private void _setMenu(final double _position) { - tabsPos = _position; - listview2.setVisibility(View.GONE); - listview1.setVisibility(View.VISIBLE); - if (_position == 0) { - childkey.clear(); - upload_list.clear(); - double _tmpNum = 0; - for (int _repeat404 = 0; _repeat404 < oldListmap.size(); _repeat404++) { - childkey.add(0, oldChildKey.get((int) (_tmpNum))); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get((int) _tmpNum); - upload_list.add(0, _item); - } - _tmpNum++; - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - if (_position == 1) { - childkey.clear(); - upload_list.clear(); - double _tmpNum = 0; - for (int _repeat58 = 0; _repeat58 < like_tmp.size(); _repeat58++) { - if (like_tmp.get((int) _tmpNum).get("uid").toString().equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) && oldChildKey.contains(like_tmp.get((int) _tmpNum).get("key").toString())) { - childkey.add(0, like_tmp.get((int) _tmpNum).get("key").toString()); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get(oldChildKey.indexOf(like_tmp.get((int) _tmpNum).get("key").toString())); - upload_list.add(0, _item); - } - } - _tmpNum++; - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - if (_position == 2) { - childkey.clear(); - upload_list.clear(); - double _tmpNum = 0; - for (int _repeat439 = 0; _repeat439 < oldListmap.size(); _repeat439++) { - double _tmpNum2 = 0; - boolean _tmp_bool = false; - for (int _repeat450 = 0; _repeat450 < upload_list.size(); _repeat450++) { - if ((Double.parseDouble(oldListmap.get((int) _tmpNum).get("view").toString()) > Double.parseDouble(upload_list.get((int) _tmpNum2).get("view").toString())) || (Double.parseDouble(oldListmap.get((int) _tmpNum).get("view").toString()) == Double.parseDouble(upload_list.get((int) _tmpNum2).get("view").toString()))) { - if (!_tmp_bool) { - childkey.add((int) (_tmpNum2), oldChildKey.get((int) (_tmpNum))); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get((int) _tmpNum); - upload_list.add((int) _tmpNum2, _item); - } - _tmp_bool = true; - } - } - _tmpNum2++; - } - if (!_tmp_bool) { - childkey.add(oldChildKey.get((int) (_tmpNum))); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get((int) _tmpNum); - upload_list.add(_item); - } - } - _tmpNum++; - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - if (_position == 3) { - childkey.clear(); - upload_list.clear(); - listview1.setVisibility(View.GONE); - listview2.setVisibility(View.VISIBLE); - listview1.setAdapter(new Listview1Adapter(upload_list)); - } - } - - private void _resetDialog() { - d = null; - d = new AlertDialog.Builder(this); - } - - private void _showPlayer() { - openNum = 2; - linear2.setTranslationX((float) (0)); - obj.setTarget(linear2); - obj.setPropertyName("translationY"); - obj.setFloatValues(SketchwareUtil.getDip(getApplicationContext(), 500), SketchwareUtil.getDip(getApplicationContext(), -200)); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(1000); - obj.start(); - obj2.setTarget(image_menu); - obj2.setPropertyName("rotation"); - obj2.setFloatValues((float) (180), (float) (0)); - obj2.setInterpolator(new DecelerateInterpolator()); - obj2.setDuration(1500); - obj2.start(); - obj3.setTarget(linear7); - obj3.setPropertyName("alpha"); - obj3.setFloatValues((float) (0), (float) (1)); - obj3.setInterpolator(new DecelerateInterpolator()); - obj3.setDuration(500); - obj3.start(); - _customNav(theme_map.get(0).get("colorPrimary").toString()); - } - - private void _addToPlaylist(final double _position, final double _listviewpos) { - if (!((playlistString.size() - 1) == _position)) { - playKeys = new Gson().fromJson(playlistMap.get((int) _position).get("keys").toString(), new TypeToken>>() { - }.getType()); - { - HashMap _item = new HashMap<>(); - _item.put("key", childkey.get((int) (_listviewpos))); - playKeys.add(_item); - } - - playlistMap.get((int) _position).put("keys", new Gson().toJson(playKeys)); - data.edit().putString("playlist", new Gson().toJson(playlistMap)).commit(); - playKeys.clear(); - _customSnack("Added!", 1); - } else { - - LinearLayout mylayout = new LinearLayout(StreamerActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(StreamerActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - - mylayout.addView(myedittext); - d.setView(mylayout); - myedittext.setHint("Enter your Playlist name"); - d.setCancelable(false); - d.setTitle("Your Playlist name"); - d.setPositiveButton("Create", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - playlistString.clear(); - { - HashMap _item = new HashMap<>(); - _item.put("key", childkey.get((int) (_listviewpos))); - playKeys.add(_item); - } - - { - HashMap _item = new HashMap<>(); - _item.put("name", myedittext.getText().toString()); - playlistMap.add(_item); - } - - playlistMap.get(playlistMap.size() - 1).put("keys", new Gson().toJson(playKeys)); - data.edit().putString("playlist", new Gson().toJson(playlistMap)).commit(); - playKeys.clear(); - for (int _repeat28 = 0; _repeat28 < playlistMap.size(); _repeat28++) { - playlistString.add(playlistMap.get(playlistString.size()).get("name").toString()); - } - playlistString.add("Add a playlist"); - ((BaseAdapter) listview2.getAdapter()).notifyDataSetChanged(); - _customSnack("Added!", 1); - } - }); - d.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } - } - - private void _deleteSongInPlaylist(final double _position) { - playKeys = new Gson().fromJson(playlistMap.get((int) numPlaylist).get("keys").toString(), new TypeToken>>() { - }.getType()); - playKeys.remove((int) (_position)); - childkey.remove((int) (_position)); - upload_list.remove((int) (_position)); - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - playlistMap.get((int) numPlaylist).put("keys", new Gson().toJson(playKeys)); - data.edit().putString("playlist", new Gson().toJson(playlistMap)).commit(); - playKeys.clear(); - _customSnack("Deleted!", 1); - } - - private void _addGrid(final double _position) { - if (!((playlistString.size() - 1) == _position)) { - isPlaylist = true; - childkey.clear(); - upload_list.clear(); - listview2.setVisibility(View.GONE); - listview1.setVisibility(View.VISIBLE); - text_zryte.setVisibility(View.GONE); - text_zene.setVisibility(View.GONE); - image_search.setVisibility(View.GONE); - image_user.setVisibility(View.GONE); - x_tab.setVisibility(View.GONE); - text_playlist.setVisibility(View.VISIBLE); - image_drawer.setImageResource(R.drawable.ic_arrow_back_white); - text_playlist.setText(playlistMap.get((int) _position).get("name").toString()); - numPlaylist = _position; - playKeys = new Gson().fromJson(playlistMap.get((int) _position).get("keys").toString(), new TypeToken>>() { - }.getType()); - double _tmpNum = 0; - for (int _repeat38 = 0; _repeat38 < playKeys.size(); _repeat38++) { - if (oldChildKey.contains(playKeys.get((int) _tmpNum).get("key").toString())) { - childkey.add(0, playKeys.get((int) _tmpNum).get("key").toString()); - { - HashMap _item = new HashMap<>(); - _item = oldListmap.get(oldChildKey.indexOf(playKeys.get((int) _tmpNum).get("key").toString())); - upload_list.add(0, _item); - } - int _index = listview1.getFirstVisiblePosition(); - View _view = listview1.getChildAt(0); - int _top = (_view == null) ? 0 : _view.getTop(); - listview1.setAdapter(new Listview1Adapter(upload_list)); - listview1.setSelectionFromTop(_index, _top); - } - _tmpNum++; - } - playKeys.clear(); - } else { - - LinearLayout mylayout = new LinearLayout(StreamerActivity.this); - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - final EditText myedittext = new EditText(StreamerActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - mylayout.addView(myedittext); - d.setView(mylayout); - myedittext.setHint("Enter your Playlist name"); - d.setCancelable(false); - d.setTitle("Your Playlist name"); - d.setPositiveButton("Create", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - playlistString.clear(); - { - HashMap _item = new HashMap<>(); - _item.put("name", myedittext.getText().toString()); - playlistMap.add(_item); - } - playlistMap.get(playlistMap.size() - 1).put("keys", "[]"); - data.edit().putString("playlist", new Gson().toJson(playlistMap)).commit(); - playKeys.clear(); - for (int _repeat66 = 0; _repeat66 < playlistMap.size(); _repeat66++) { - playlistString.add(playlistMap.get(playlistString.size()).get("name").toString()); - } - playlistString.add("Add a playlist"); - ((BaseAdapter) listview2.getAdapter()).notifyDataSetChanged(); - _customSnack("Added!", 1); - } - }); - d.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } - } - - private void _delGrid(final double _position) { - if (!((playlistString.size() - 1) == _position)) { - d.setCancelable(false); - d.setTitle("Delete"); - d.setMessage("Are you sure to delete this playlist?"); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - playlistMap.remove((int) (_position)); - playlistString.remove((int) (_position)); - ((BaseAdapter) listview2.getAdapter()).notifyDataSetChanged(); - data.edit().putString("playlist", new Gson().toJson(playlistMap)).commit(); - _customSnack("Deleted!", 1); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } - } - - private void _play(final String _key) { - _CoreProgressLoading(true); - final int _pos = (int) currentlyChild.indexOf(_key); - tempMap = currentlyMap.get(_pos); - currentlyPlaying = _key; - text_title.setText(tempMap.get("name").toString()); - if (usrname_list.contains(tempMap.get("uid").toString())) { - text_artist.setText(profile_map.get(usrname_list.indexOf(tempMap.get("uid").toString())).get("username").toString()); - } else { - text_artist.setText(tempMap.get("uid").toString()); - } - if (adminsList.contains(tempMap.get("uid").toString())) { - text_artist.setTextColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - } else { - text_artist.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryCardText").toString())); - } - if (tempMap.containsKey("img")) { - image_album.clearColorFilter(); - Glide.with(getApplicationContext()).load(tempMap.get("img").toString()).centerCrop().into(image_album); - } else { - image_album.setImageResource(R.drawable.ic_album_white); - image_album.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - } - zz.play(tempMap.get("url").toString(), tempMap.get("name").toString(), "ZryteZene", tempMap.containsKey("img") ? tempMap.get("img").toString() : "-"); - } - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - private void _abandonFocus() { - View _tmpView = this.getCurrentFocus(); - if (_tmpView != null) { - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(_tmpView.getWindowToken(), 0); - } - } - - private void _mpPreparedListener() { - final double _position = currentlyChild.indexOf(currentlyPlaying); - if (data.getString("nightcore", "").equals("1")) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - float _tmpFloat = 1.10f + ((float) Double.parseDouble(data.getString("nightcoreSpeed", "")) * 0.05f); - //tmservice._setNightcore(_tmpFloat); - } else { - data.edit().putString("nightcore", "0").commit(); - image_nightcore.setAlpha((float) (0.5d)); - _customSnack("Android Lollipop or lower doesn't support nightcore feature!", 2); - } - } - _CoreProgressLoading(false); - _refreshLikes(); - if (openNum == 0) { - _showPlayer(); - } - upload_map = new HashMap<>(); - upload_map = currentlyMap.get((int) _position); - upload_map.put("view", String.valueOf((long) (Double.parseDouble(upload_map.get("view").toString()) + 1))); - upload_text.child(currentlyPlaying).updateChildren(upload_map); - } - - private void _mpErrorListener(final String _errorMsg) { - _CoreProgressLoading(false); - _customSnack(_errorMsg, 2); - currentlyPlaying = ""; - openNum = 0; - obj.setTarget(linear2); - obj.setPropertyName("translationX"); - obj.setFloatValues((float) (0), (float) (SketchwareUtil.getDisplayWidthPixels(getApplicationContext()) + SketchwareUtil.getDisplayHeightPixels(getApplicationContext()))); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - _customNav(theme_map.get(0).get("colorBackground").toString()); - zz.clear(); - currentlyMap.clear(); - currentlyChild.clear(); - } - - private void _mpBufferingUpdate(final double _percent) { - try { - //seekbar1.setSecondaryProgress(((int) _percent * tmservice._getSongDuration()) / 100000); - } catch (Exception _e) { - } - } - - private void _mpCompletionListener() { - final double _position = currentlyChild.indexOf(currentlyPlaying); - if (data.getString("fvsAsc", "").equals("0")) { - if (currentlyMap.size() > (_position + 1)) { - _play(currentlyChild.get((int) (_position + 1))); - } else { - currentlyPlaying = ""; - openNum = 0; - obj.setTarget(linear2); - obj.setPropertyName("translationX"); - obj.setFloatValues((float) (0), (float) (SketchwareUtil.getDisplayWidthPixels(getApplicationContext()) + SketchwareUtil.getDisplayHeightPixels(getApplicationContext()))); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - _customNav(theme_map.get(0).get("colorBackground").toString()); - zz.clear(); - currentlyMap.clear(); - currentlyChild.clear(); - } - } else { - if (data.getString("fvsAsc", "").equals("1")) { - if (currentlyMap.size() > (_position + 1)) { - _play(currentlyChild.get((int) (_position + 1))); - } else { - _play(currentlyChild.get(0)); - } - } else { - if (data.getString("fvsAsc", "").equals("2")) { - //tmservice._mpSeek(0); - //tmservice._mpStart(); - zz.requestAction("restart-song"); - upload_map = new HashMap<>(); - upload_map = currentlyMap.get((int) _position); - upload_map.put("view", String.valueOf((long) (Double.parseDouble(upload_map.get("view").toString()) + 1))); - upload_text.child(currentlyPlaying).updateChildren(upload_map); - } else { - _play(currentlyChild.get(SketchwareUtil.getRandom(0, currentlyMap.size() - 1))); - } - } - } - } - - private void _updateTime() { - try { - if (zz.isPlaying()) { - image_play.setImageResource(R.drawable.ic_pause_white); - seekbar1.setProgress(zz.getCurrentDuration() / 1000); - } else { - image_play.setImageResource(R.drawable.ic_play_arrow_white); - } - } catch (Exception _e) { - } - } - - private void _handleMpError(final String _msg) { - _CoreProgressLoading(false); - _customSnack(_msg, 2); - currentlyPlaying = ""; - openNum = 0; - obj.setTarget(linear2); - obj.setPropertyName("translationX"); - obj.setFloatValues((float) (0), (float) (SketchwareUtil.getDisplayWidthPixels(getApplicationContext()) + SketchwareUtil.getDisplayHeightPixels(getApplicationContext()))); - obj.setInterpolator(new DecelerateInterpolator()); - obj.setDuration(500); - obj.start(); - _customNav(theme_map.get(0).get("colorBackground").toString()); - zz.requestAction("reset"); - currentlyMap.clear(); - currentlyChild.clear(); - } - - private void _bindSvc() { - } - - private void _unbindSvc() { - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public class Listview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Listview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.list, null); - } - - final LinearLayout linear_base = _v.findViewById(R.id.linear_base); - final ImageView imageview4 = _v.findViewById(R.id.imageview4); - final LinearLayout linear3 = _v.findViewById(R.id.linear3); - final LinearLayout linear4 = _v.findViewById(R.id.linear4); - final ImageView imageview5 = _v.findViewById(R.id.imageview5); - final ImageView imageview6 = _v.findViewById(R.id.imageview6); - final LinearLayout linear5 = _v.findViewById(R.id.linear5); - final TextView textview1 = _v.findViewById(R.id.textview1); - final TextView textview2 = _v.findViewById(R.id.textview2); - final LinearLayout linear2 = _v.findViewById(R.id.linear2); - final ImageView imageview1 = _v.findViewById(R.id.imageview1); - final TextView textview3 = _v.findViewById(R.id.textview3); - final ImageView imageview2 = _v.findViewById(R.id.imageview2); - final TextView textview4 = _v.findViewById(R.id.textview4); - final ImageView imageview3 = _v.findViewById(R.id.imageview3); - final TextView textview5 = _v.findViewById(R.id.textview5); - - try { - if (!animateList.contains(String.valueOf((long) (_position)))) { - animateList.add(String.valueOf((long) (_position))); - TranslateAnimation _animate = new TranslateAnimation(0, 0, linear_base.getHeight(), 0); - _animate.setDuration(500); - _animate.setFillAfter(true); - linear_base.startAnimation(_animate); - } - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (adminsList.contains(upload_list.get(_position).get("uid").toString())) { - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - android.graphics.drawable.GradientDrawable _gD = new android.graphics.drawable.GradientDrawable(); - _gD.setColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - _gD.setShape(android.graphics.drawable.GradientDrawable.OVAL); - _gD.setStroke(5, Color.parseColor(theme_map.get(0).get("colorButton").toString())); - imageview6.setBackground(_gD); - } else { - textview2.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - imageview6.setBackgroundColor(Color.TRANSPARENT); - } - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - textview3.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString())); - imageview2.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.MULTIPLY); - textview4.setTextColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - imageview3.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - textview5.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString())); - linear_base.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(theme_map.get(0).get("colorRipple").toString()))); - linear_base.setClickable(true); - linear3.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - imageview5.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview5.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - if (img_maps.containsKey(upload_list.get(_position).get("uid").toString())) { - imageview6.clearColorFilter(); - Glide.with(getApplicationContext()).asBitmap().load(img_maps.get(upload_list.get(_position).get("uid").toString()).toString()).centerCrop().into(new com.bumptech.glide.request.target.BitmapImageViewTarget(imageview6) { - @Override - protected void setResource(Bitmap resource) { - androidx.core.graphics.drawable.RoundedBitmapDrawable circularBitmapDrawable = androidx.core.graphics.drawable.RoundedBitmapDrawableFactory.create(getApplicationContext().getResources(), resource); - circularBitmapDrawable.setCircular(true); - imageview6.setImageDrawable(circularBitmapDrawable); - } - }); - } else { - imageview6.setColorFilter(Color.parseColor(theme_map.get(0).get("colorBackgroundImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview6.setImageResource(R.drawable.ic_person); - } - if (data.getString("showPreview", "").equals("1")) { - if (upload_list.get(_position).containsKey("img")) { - linear3.setVisibility(View.GONE); - imageview4.setVisibility(View.VISIBLE); - Glide.with(getApplicationContext()).load(Uri.parse(upload_list.get(_position).get("img").toString())).into(imageview4); - } else { - linear3.setVisibility(View.VISIBLE); - imageview4.setVisibility(View.GONE); - } - } else { - linear3.setVisibility(View.GONE); - imageview4.setVisibility(View.GONE); - } - textview1.setText(upload_list.get(_position).get("name").toString()); - if (usrname_list.contains(upload_list.get(_position).get("uid").toString())) { - textview2.setText(profile_map.get(usrname_list.indexOf(upload_list.get(_position).get("uid").toString())).get("username").toString()); - } else { - textview2.setText(upload_list.get(_position).get("uid").toString()); - } - if (Double.parseDouble(upload_list.get(_position).get("view").toString()) > 999) { - textview3.setText(new DecimalFormat("0.00").format(Double.parseDouble(upload_list.get(_position).get("view").toString()) / 1000).concat("K")); - } else { - textview3.setText(upload_list.get(_position).get("view").toString()); - } - if (likes_map.containsKey(childkey.get(_position))) { - textview4.setText(likes_map.get(childkey.get(_position)).toString()); - } else { - textview4.setText("0"); - } - if (commentsMap.containsKey(childkey.get(_position))) { - textview5.setText(commentsMap.get(childkey.get(_position)).toString()); - } else { - textview5.setText("0"); - } - linear_base.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - //if (tmservice != null) { - currentlyMap.clear(); - currentlyChild.clear(); - for (int _repeat244 = 0; _repeat244 < upload_list.size(); _repeat244++) { - { - HashMap _item = new HashMap<>(); - _item = upload_list.get(currentlyMap.size()); - currentlyMap.add(_item); - } - } - for (int _repeat246 = 0; _repeat246 < childkey.size(); _repeat246++) { - currentlyChild.add(childkey.get(currentlyChild.size())); - } - _play(currentlyChild.get(_position)); - //} - } - }); - linear_base.setOnLongClickListener(new View.OnLongClickListener() { - @Override - public boolean onLongClick(View _view) { - if (!(tabsPos == 3)) { - d.setCancelable(false); - d.setAdapter(new ArrayAdapter(StreamerActivity.this, android.R.layout.simple_list_item_1, dialog_list), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dia, int _pos_dialog) { - _resetDialog(); - if (_pos_dialog == 0) { - intent.setClass(getApplicationContext(), ProfileActivity.class); - intent.putExtra("uid", upload_list.get(_position).get("uid").toString()); - startActivity(intent); - } else { - if (_pos_dialog == 1) { - if (upload_list.get(_position).get("uid").toString().equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) || isAdmin) { - d.setCancelable(false); - d.setTitle("Delete Music?"); - d.setMessage("Are You Sure To Delete ".concat(upload_list.get(_position).get("name").toString().concat("?"))); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - FirebaseStorage.getInstance().getReferenceFromUrl(upload_list.get(_position).get("url").toString()).delete().addOnSuccessListener(_upload_storage_delete_success_listener).addOnFailureListener(_upload_storage_failure_listener); - if (upload_list.get(_position).containsKey("img")) { - FirebaseStorage.getInstance().getReferenceFromUrl(upload_list.get(_position).get("img").toString()).delete().addOnSuccessListener(_music_image_delete_success_listener).addOnFailureListener(_music_image_failure_listener); - } - upload_text.child(childkey.get(_position)).removeValue(); - _customSnack("Delete success!", 1); - _resetDialog(); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } else { - _customSnack("Can't delete! Access denied.", 2); - } - } else { - if (_pos_dialog == 2) { - intent.setClass(getApplicationContext(), MessageActivity.class); - intent.putExtra("key", childkey.get(_position)); - startActivity(intent); - } else { - if (_pos_dialog == 3) { - d.setCancelable(false); - d.setAdapter(new ArrayAdapter(StreamerActivity.this, android.R.layout.simple_list_item_1, playlistString), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dia, int _pos_dialog2) { - _resetDialog(); - _addToPlaylist(_pos_dialog2, _position); - } - }); - d.show(); - } else { - if (_pos_dialog == 4) { - - } - } - } - } - } - } - }); - - d.show(); - } else { - d.setCancelable(false); - d.setTitle("Delete"); - d.setMessage("Are you sure to delete this song from your playlist?"); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - _deleteSongInPlaylist(_position); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - } - }); - d.create().show(); - } - return true; - } - }); - } catch (Exception _e) { - showMessage("DEBUG: " + _e.getMessage()); - } - - return _v; - } - } -} diff --git a/app/src/main/java/tw/music/streamer/StreamingActivity.java b/app/src/main/java/tw/music/streamer/StreamingActivity.java index 8690ac7..ffaa819 100644 --- a/app/src/main/java/tw/music/streamer/StreamingActivity.java +++ b/app/src/main/java/tw/music/streamer/StreamingActivity.java @@ -21,11 +21,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.GridLayoutManager; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.RequestOptions; -import com.bumptech.glide.load.engine.DiskCacheStrategy; -import com.bumptech.glide.load.resource.bitmap.RoundedCorners; - import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseReference; @@ -41,11 +36,12 @@ import tw.music.streamer.adapter.ZZOnClickListener; import tw.music.streamer.adapter.ZZRandomSongAdapter; import tw.music.streamer.service.ZryteZenePlay; +import tw.music.streamer.loader.ZryteZeneImageLoader; public class StreamingActivity extends AppCompatActivity { private FirebaseAuth auth; - private DatabaseReference db_song, db_drsong; + private DatabaseReference db_song, db_drsong, me_db; private StorageReference fs_music; private BroadcastReceiver zzreceiver; @@ -62,7 +58,7 @@ public class StreamingActivity extends AppCompatActivity { private ZryteZeneAdaptor zz; private ZZRandomSongAdapter ra_songs; private ZZSongAdapter ar_songs; - private ZZOnClickListener zz_click1; + private ZZOnClickListener zz_click1, zz_click2; private int openMenu = 0; @@ -80,14 +76,20 @@ protected void onCreate(Bundle a) { } private void initVariables(Context a) { + ZryteZeneImageLoader.getInstance(a); zz_songs = new ArrayList<>(); zz_songs2 = new ArrayList<>(); zz_click1 = new ZZOnClickListener() { public void onItemClicked(int a) { - playFromZZSongs(a); + playFromZZSongs(zz_songs.get(a)); } }; - ra_songs = new ZZRandomSongAdapter(zz_songs2); + zz_click2 = new ZZOnClickListener() { + public void onItemClicked(int a) { + playFromZZSongs(zz_songs2.get(a)); + } + }; + ra_songs = new ZZRandomSongAdapter(zz_songs2, zz_click2); ar_songs = new ZZSongAdapter(zz_songs, zz_click1); lm1 = new LinearLayoutManager(a, LinearLayoutManager.HORIZONTAL, false); lm2 = new GridLayoutManager(a, 2); @@ -97,6 +99,7 @@ private void initFirebase() { auth = FirebaseAuth.getInstance(); db_song = FirebaseDatabase.getInstance().getReference("zrytezene/songs"); db_drsong = FirebaseDatabase.getInstance().getReference("zrytezene/daily-random-songs"); + me_db = FirebaseDatabase.getInstance().getReference("profile/text/" + auth.getCurrentUser().getUid()); } private void initFirebaseListener(final Context z) { @@ -108,11 +111,7 @@ private void initFirebaseListener(final Context z) { zz_songs.add(new ZZSong(c)); } ar_songs.notifyDataSetChanged(); - } else { - // songs empty } - } else { - // error: task.getException().getMessage() } }); @@ -132,7 +131,7 @@ private void initFirebaseListener(final Context z) { if (a.isSuccessful()) { DataSnapshot b = a.getResult(); if (b.exists() && b.hasChild("url")) { - Glide.with(z).load(b.child("url").getValue(String.class)).diskCacheStrategy(DiskCacheStrategy.ALL).apply(RequestOptions.circleCropTransform()).into(user_icon); + ZryteZeneImageLoader.getInstance(z).loadWithCircularOutput(b.child("url").getValue(String.class),user_icon); } } }); @@ -250,6 +249,8 @@ public void onReceive(Context context, Intent intent) { zz.setDuration(intent.getIntExtra("data",0)/1000); mp_bar.setProgress(0); mp_bar.setMax(zz.getDuration()); + zz.setKey(intent.getStringExtra("key")); + updateLastSongPlayed(); } else if (m.equals("on-reqmedia")) { int b = intent.getIntExtra("status",0); if (b > 0) { @@ -299,15 +300,20 @@ public void onReceive(Context context, Intent intent) { zz.requestAction("request-media"); } - private void playFromZZSongs(int a) { - mp_artist.setText(zz_songs.get(a).song_artist); - mp_title.setText(zz_songs.get(a).song_name); + private void saveSongsMetadata() { + //Gson temp = new Gson(); + zz.requestAction("load-songs"); + } + + private void playFromZZSongs(ZZSong a) { + mp_artist.setText(a.song_artist); + mp_title.setText(a.song_name); mp_play.setImageResource(R.drawable.ic_pause_white); - Glide.with(getApplicationContext()).load(zz_songs.get(a).url_icon).diskCacheStrategy(DiskCacheStrategy.ALL).transform(new RoundedCorners(dip(5))).into(mp_icon); + ZryteZeneImageLoader.getInstance(getApplicationContext()).loadWithRoundOutput(a.url_icon, mp_icon, dip(4)); mp_base.setVisibility(View.VISIBLE); - Glide.with(getApplicationContext()).load(zz_songs.get(a).url_cover).diskCacheStrategy(DiskCacheStrategy.ALL).into(bg_drop); - mp_bar.setProgressTintList(ColorStateList.valueOf(Color.parseColor(zz_songs.get(a).color1))); - zz.play(zz_songs.get(a)); + ZryteZeneImageLoader.getInstance(getApplicationContext()).load(a.url_cover, bg_drop); + mp_bar.setProgressTintList(ColorStateList.valueOf(Color.parseColor(a.color1))); + zz.play(a); } private void loadSongFromKey(String a) { @@ -318,15 +324,19 @@ private void loadSongFromKey(String a) { bg_drop.setVisibility(View.VISIBLE); mp_artist.setText(c.child("artist").getValue(String.class)); mp_title.setText(c.child("title").getValue(String.class)); - Glide.with(getApplicationContext()).load(c.child("icon").getValue(String.class)).diskCacheStrategy(DiskCacheStrategy.ALL).transform(new RoundedCorners(dip(5))).into(mp_icon); + ZryteZeneImageLoader.getInstance(getApplicationContext()).loadWithRoundOutput(c.child("icon").getValue(String.class), mp_icon, dip(4)); mp_base.setVisibility(View.VISIBLE); - Glide.with(getApplicationContext()).load(c.child("cover").getValue(String.class)).diskCacheStrategy(DiskCacheStrategy.ALL).into(bg_drop); + ZryteZeneImageLoader.getInstance(getApplicationContext()).load(c.child("cover").getValue(String.class), bg_drop); mp_bar.setProgressTintList(ColorStateList.valueOf(Color.parseColor(c.child("color-bline").getValue(String.class)))); } } }); } + private void updateLastSongPlayed() { + me_db.child("last-song-key").setValue(zz.getKey()); + } + private void openMenuBar(int a, boolean b) { if (a==openMenu) return; tapicon1.setColorFilter(0xFF757575, PorterDuff.Mode.MULTIPLY); @@ -399,4 +409,4 @@ private int dip(int a) { return (int) (a * getApplicationContext().getResources().getDisplayMetrics().density); } -} \ No newline at end of file +} diff --git a/app/src/main/java/tw/music/streamer/SwthomeActivity.java b/app/src/main/java/tw/music/streamer/SwthomeActivity.java deleted file mode 100644 index b8e12b2..0000000 --- a/app/src/main/java/tw/music/streamer/SwthomeActivity.java +++ /dev/null @@ -1,332 +0,0 @@ -package tw.music.streamer; - -import android.app.ProgressDialog; -import android.content.Context; -import android.content.Intent; -import android.graphics.Color; -import android.graphics.Typeface; -import android.media.AudioManager; -import android.media.MediaPlayer; -import android.os.Build; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.Window; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.MediaController; -import android.widget.TextView; -import android.widget.Toast; -import android.widget.VideoView; - -import androidx.appcompat.app.AppCompatActivity; - -import java.util.ArrayList; -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; - -public class SwthomeActivity extends AppCompatActivity { - - private Timer _timer = new Timer(); - - private LinearLayout linear1; - private LinearLayout linear2; - private LinearLayout linear4; - private TextView textview1; - private LinearLayout linear3; - private TextView textview2; - private TextView textview3; - private TextView textview4; - - private TimerTask delay; - private MediaPlayer mp; - private VideoView videoview1; - private MediaController vidcontrol; - private ProgressDialog coreprog; - - { - } - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.swthome); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - linear4 = findViewById(R.id.linear4); - textview1 = findViewById(R.id.textview1); - linear3 = findViewById(R.id.linear3); - textview2 = findViewById(R.id.textview2); - textview3 = findViewById(R.id.textview3); - textview4 = findViewById(R.id.textview4); - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - getWindow().getDecorView().setSystemUiVisibility( - View.SYSTEM_UI_FLAG_LAYOUT_STABLE - | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN - | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION - | View.SYSTEM_UI_FLAG_FULLSCREEN - | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); - _customNav("#000000"); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - if (getIntent().getStringExtra("eg").equals("0")) { - linear2.setVisibility(View.GONE); - linear4.setVisibility(View.GONE); - } else { - if (getIntent().getStringExtra("eg").equals("1")) { - linear1.setVisibility(View.GONE); - linear4.setVisibility(View.GONE); - try { - mp = new MediaPlayer(); - mp.setAudioStreamType(AudioManager.STREAM_MUSIC); - mp.setDataSource("https://rainymood.com/audio1112/0.m4a"); - _CoreProgressLoading(true); - mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { - public void onPrepared(MediaPlayer _unmp) { - _CoreProgressLoading(false); - mp.setLooping(true); - mp.start(); - } - }); - mp.prepareAsync(); - } catch (Exception _e) { - } - } else { - if (getIntent().getStringExtra("eg").equals("2")) { - linear1.setVisibility(View.GONE); - linear2.setVisibility(View.GONE); - textview4.setText("Axhyre"); - delay = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - textview4.setText("is"); - delay = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - textview4.setText("a"); - delay = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - textview4.setText("gud"); - delay = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - textview4.setText("boy"); - delay = new TimerTask() { - @Override - public void run() { - runOnUiThread(new Runnable() { - @Override - public void run() { - textview4.setText("ax."); - } - }); - } - }; - _timer.schedule(delay, 2000); - } - }); - } - }; - _timer.schedule(delay, 2000); - } - }); - } - }; - _timer.schedule(delay, 2000); - } - }); - } - }; - _timer.schedule(delay, 2000); - } - }); - } - }; - _timer.schedule(delay, 2000); - } else { - - } - } - } - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onBackPressed() { - if (getIntent().getStringExtra("eg").equals("0")) { - try { - delay.cancel(); - } catch (Exception _e) { - } - finish(); - } else { - if (getIntent().getStringExtra("eg").equals("1")) { - mp.stop(); - finish(); - } else { - if (getIntent().getStringExtra("eg").equals("2")) { - try { - delay.cancel(); - } catch (Exception _e) { - } - finish(); - } else { - - } - } - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _CoreProgressLoading(final boolean _ifShow) { - if (_ifShow) { - if (coreprog == null) { - coreprog = new ProgressDialog(this); - coreprog.setCancelable(false); - coreprog.setCanceledOnTouchOutside(false); - - coreprog.requestWindowFeature(Window.FEATURE_NO_TITLE); - coreprog.getWindow().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(Color.TRANSPARENT)); - - } - coreprog.setMessage(null); - coreprog.show(); - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _coreView = _inflater.inflate(R.layout.custom_dialog, null); - final ImageView imageview1 = _coreView.findViewById(R.id.imageview1); - com.bumptech.glide.Glide.with(getApplicationContext()).load(R.raw.partyblob).into(imageview1); - coreprog.setContentView(_coreView); - } else { - if (coreprog != null) { - coreprog.dismiss(); - } - } - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - -} diff --git a/app/src/main/java/tw/music/streamer/ThemesActivity.java b/app/src/main/java/tw/music/streamer/ThemesActivity.java deleted file mode 100644 index 99c0fe2..0000000 --- a/app/src/main/java/tw/music/streamer/ThemesActivity.java +++ /dev/null @@ -1,1639 +0,0 @@ -package tw.music.streamer; - -import android.Manifest; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.text.Editable; -import android.text.InputType; -import android.text.TextWatcher; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; -import android.widget.BaseAdapter; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.EditText; -import android.widget.GridLayout; -import android.widget.GridView; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ScrollView; -import android.widget.SeekBar; -import android.widget.Spinner; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; - -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -public class ThemesActivity extends AppCompatActivity { - - - private FloatingActionButton _fab; - private boolean isPanel = false; - private boolean isEditing = false; - private double posEdit = 0; - private String tmpPath = ""; - private HashMap tmpMAPM = new HashMap<>(); - - private ArrayList> themes_map = new ArrayList<>(); - private ArrayList spinnerList = new ArrayList<>(); - private ArrayList> gridMap = new ArrayList<>(); - private ArrayList> gridtmp = new ArrayList<>(); - private ArrayList indexDataList = new ArrayList<>(); - private ArrayList dialog_list = new ArrayList<>(); - private ArrayList> tmpMAPC = new ArrayList<>(); - private ArrayList> tmpMAPJ = new ArrayList<>(); - - private LinearLayout linear_title; - private LinearLayout linear_grid; - private ScrollView vscroll1; - private ImageView image_back; - private TextView text_back; - private ImageView image_import; - private LinearLayout linear_panel; - private LinearLayout linear15; - private LinearLayout colprimlin; - private LinearLayout colprimtextlin; - private LinearLayout colprimdarklin; - private LinearLayout sttsbrlin; - private LinearLayout colbglin; - private LinearLayout colbgtxtlin; - private LinearLayout colbttnlin; - private LinearLayout colbttntxtlin; - private LinearLayout sdwlin; - private LinearLayout colriplin; - private LinearLayout colhntlin; - private LinearLayout colprimimglin; - private LinearLayout colbgimglin; - private LinearLayout linear9; - private LinearLayout linear10; - private LinearLayout linear11; - private LinearLayout linear12; - private LinearLayout linear13; - private LinearLayout linear14; - private Button button_save; - private LinearLayout linear18; - private LinearLayout linear16; - private TextView textview20; - private LinearLayout linear17; - private ImageView imageview2; - private ImageView imageview3; - private LinearLayout linear19; - private ImageView imageview6; - private ImageView imageview5; - private ImageView imageview4; - private TextView textview21; - private ImageView imageview1; - private TextView textview18; - private TextView textview19; - private TextView colprimtext; - private TextView textview1; - private Button button1; - private TextView colprimtxttext; - private TextView textview9; - private Button button9; - private TextView colprimdarktext; - private TextView textview2; - private Button button2; - private TextView sttsbrtext; - private Spinner sttsbrspin; - private TextView colbgtext; - private TextView textview3; - private Button button3; - private TextView colbgtxttext; - private TextView textview10; - private Button button10; - private TextView colbttntext; - private TextView textview4; - private Button button4; - private TextView colbttntxttext; - private TextView textview11; - private Button button11; - private TextView sdwtext; - private CheckBox sdwchkbx; - private TextView colriptext; - private TextView textview5; - private Button button5; - private TextView colhnttext; - private TextView textview6; - private Button button6; - private TextView colprimimgtxt; - private TextView textview7; - private Button button7; - private TextView colbgimgtxt; - private TextView textview8; - private Button button8; - private TextView colprimcrd; - private TextView textview12; - private Button button12; - private TextView colbgcrd; - private TextView textview13; - private Button button13; - private TextView colprimcrdtxt; - private TextView textview14; - private Button button14; - private TextView colbgcrdtxt; - private TextView textview15; - private Button button15; - private TextView colprimcrdimg; - private TextView textview16; - private Button button16; - private TextView colbgcrdimg; - private TextView textview17; - private Button button17; - - private SharedPreferences data; - private AlertDialog.Builder dialog; - private Intent i = new Intent(); - private AlertDialog.Builder dialog2; - private AlertDialog.Builder dialog3; - private AlertDialog.Builder colorPicker; - private AlertDialog.Builder dialog4; - private GridView grid; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.themes); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED - || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000); - } else { - initializeLogic(); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1000) { - initializeLogic(); - } - } - - private void initialize(Bundle _savedInstanceState) { - - _fab = findViewById(R.id._fab); - - linear_title = findViewById(R.id.linear_title); - linear_grid = findViewById(R.id.linear_grid); - vscroll1 = findViewById(R.id.vscroll1); - image_back = findViewById(R.id.image_back); - text_back = findViewById(R.id.text_back); - image_import = findViewById(R.id.image_import); - linear_panel = findViewById(R.id.linear_panel); - linear15 = findViewById(R.id.linear15); - colprimlin = findViewById(R.id.colprimlin); - colprimtextlin = findViewById(R.id.colprimtextlin); - colprimdarklin = findViewById(R.id.colprimdarklin); - sttsbrlin = findViewById(R.id.sttsbrlin); - colbglin = findViewById(R.id.colbglin); - colbgtxtlin = findViewById(R.id.colbgtxtlin); - colbttnlin = findViewById(R.id.colbttnlin); - colbttntxtlin = findViewById(R.id.colbttntxtlin); - sdwlin = findViewById(R.id.sdwlin); - colriplin = findViewById(R.id.colriplin); - colhntlin = findViewById(R.id.colhntlin); - colprimimglin = findViewById(R.id.colprimimglin); - colbgimglin = findViewById(R.id.colbgimglin); - linear9 = findViewById(R.id.linear9); - linear10 = findViewById(R.id.linear10); - linear11 = findViewById(R.id.linear11); - linear12 = findViewById(R.id.linear12); - linear13 = findViewById(R.id.linear13); - linear14 = findViewById(R.id.linear14); - button_save = findViewById(R.id.button_save); - linear18 = findViewById(R.id.linear18); - linear16 = findViewById(R.id.linear16); - textview20 = findViewById(R.id.textview20); - linear17 = findViewById(R.id.linear17); - imageview2 = findViewById(R.id.imageview2); - imageview3 = findViewById(R.id.imageview3); - linear19 = findViewById(R.id.linear19); - imageview6 = findViewById(R.id.imageview6); - imageview5 = findViewById(R.id.imageview5); - imageview4 = findViewById(R.id.imageview4); - textview21 = findViewById(R.id.textview21); - imageview1 = findViewById(R.id.imageview1); - textview18 = findViewById(R.id.textview18); - textview19 = findViewById(R.id.textview19); - colprimtext = findViewById(R.id.colprimtext); - textview1 = findViewById(R.id.textview1); - button1 = findViewById(R.id.button1); - colprimtxttext = findViewById(R.id.colprimtxttext); - textview9 = findViewById(R.id.textview9); - button9 = findViewById(R.id.button9); - colprimdarktext = findViewById(R.id.colprimdarktext); - textview2 = findViewById(R.id.textview2); - button2 = findViewById(R.id.button2); - sttsbrtext = findViewById(R.id.sttsbrtext); - sttsbrspin = findViewById(R.id.sttsbrspin); - colbgtext = findViewById(R.id.colbgtext); - textview3 = findViewById(R.id.textview3); - button3 = findViewById(R.id.button3); - colbgtxttext = findViewById(R.id.colbgtxttext); - textview10 = findViewById(R.id.textview10); - button10 = findViewById(R.id.button10); - colbttntext = findViewById(R.id.colbttntext); - textview4 = findViewById(R.id.textview4); - button4 = findViewById(R.id.button4); - colbttntxttext = findViewById(R.id.colbttntxttext); - textview11 = findViewById(R.id.textview11); - button11 = findViewById(R.id.button11); - sdwtext = findViewById(R.id.sdwtext); - sdwchkbx = findViewById(R.id.sdwchkbx); - colriptext = findViewById(R.id.colriptext); - textview5 = findViewById(R.id.textview5); - button5 = findViewById(R.id.button5); - colhnttext = findViewById(R.id.colhnttext); - textview6 = findViewById(R.id.textview6); - button6 = findViewById(R.id.button6); - colprimimgtxt = findViewById(R.id.colprimimgtxt); - textview7 = findViewById(R.id.textview7); - button7 = findViewById(R.id.button7); - colbgimgtxt = findViewById(R.id.colbgimgtxt); - textview8 = findViewById(R.id.textview8); - button8 = findViewById(R.id.button8); - colprimcrd = findViewById(R.id.colprimcrd); - textview12 = findViewById(R.id.textview12); - button12 = findViewById(R.id.button12); - colbgcrd = findViewById(R.id.colbgcrd); - textview13 = findViewById(R.id.textview13); - button13 = findViewById(R.id.button13); - colprimcrdtxt = findViewById(R.id.colprimcrdtxt); - textview14 = findViewById(R.id.textview14); - button14 = findViewById(R.id.button14); - colbgcrdtxt = findViewById(R.id.colbgcrdtxt); - textview15 = findViewById(R.id.textview15); - button15 = findViewById(R.id.button15); - colprimcrdimg = findViewById(R.id.colprimcrdimg); - textview16 = findViewById(R.id.textview16); - button16 = findViewById(R.id.button16); - colbgcrdimg = findViewById(R.id.colbgcrdimg); - textview17 = findViewById(R.id.textview17); - button17 = findViewById(R.id.button17); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - dialog = new AlertDialog.Builder(this); - dialog2 = new AlertDialog.Builder(this); - dialog3 = new AlertDialog.Builder(this); - colorPicker = new AlertDialog.Builder(this); - dialog4 = new AlertDialog.Builder(this); - - image_back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - onBackPressed(); - } - }); - - image_import.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - i.setClass(getApplicationContext(), FilepickerActivity.class); - i.putExtra("fileType", "os-thm"); - startActivity(i); - } - }); - - button_save.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - LinearLayout mylayout = new LinearLayout(ThemesActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(ThemesActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - - final EditText myedittext_author = new EditText(ThemesActivity.this); - myedittext_author.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext_author.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - - final EditText myedittext_info = new EditText(ThemesActivity.this); - myedittext_info.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext_info.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - if (isEditing) { - myedittext.setText(gridMap.get((int) posEdit).get("themesname").toString()); - if (gridMap.get((int) posEdit).containsKey("themesauthor")) - myedittext_author.setText(gridMap.get((int) posEdit).get("themesauthor").toString()); - if (gridMap.get((int) posEdit).containsKey("themesinfo")) - myedittext_info.setText(gridMap.get((int) posEdit).get("themesinfo").toString()); - } - - mylayout.addView(myedittext); - mylayout.addView(myedittext_author); - mylayout.addView(myedittext_info); - dialog2.setView(mylayout); - myedittext.setHint("Theme Name"); - myedittext_author.setHint("Author Name"); - myedittext_info.setHint("Theme Info"); - dialog2.setCancelable(false); - dialog2.setTitle("Enter your theme metadata"); - dialog2.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - if (!((myedittext.getText().toString().trim().length() == 0) || myedittext.getText().toString().contains("$")) && (!(myedittext_author.getText().toString().trim().length() == 0) && !(myedittext_info.getText().toString().trim().length() == 0))) { - themes_map.clear(); - { - HashMap _item = new HashMap<>(); - _item.put("colorPrimary", textview1.getText().toString()); - themes_map.add(_item); - } - - themes_map.get(0).put("colorPrimaryText", textview9.getText().toString()); - themes_map.get(0).put("colorPrimaryDark", textview2.getText().toString()); - themes_map.get(0).put("statusbarIcon", String.valueOf((long) (sttsbrspin.getSelectedItemPosition()))); - themes_map.get(0).put("colorBackground", textview3.getText().toString()); - themes_map.get(0).put("colorBackgroundText", textview10.getText().toString()); - themes_map.get(0).put("colorButton", textview4.getText().toString()); - themes_map.get(0).put("colorButtonText", textview11.getText().toString()); - if (sdwchkbx.isChecked()) { - themes_map.get(0).put("shadow", "1"); - } else { - themes_map.get(0).put("shadow", "0"); - } - themes_map.get(0).put("colorRipple", textview5.getText().toString()); - themes_map.get(0).put("colorHint", textview6.getText().toString()); - themes_map.get(0).put("colorPrimaryImage", textview7.getText().toString()); - themes_map.get(0).put("colorBackgroundImage", textview8.getText().toString()); - themes_map.get(0).put("colorPrimaryCard", textview12.getText().toString()); - themes_map.get(0).put("colorBackgroundCard", textview13.getText().toString()); - themes_map.get(0).put("colorPrimaryCardText", textview14.getText().toString()); - themes_map.get(0).put("colorBackgroundCardText", textview15.getText().toString()); - themes_map.get(0).put("colorPrimaryCardImage", textview16.getText().toString()); - themes_map.get(0).put("colorBackgroundCardImage", textview17.getText().toString()); - themes_map.get(0).put("version", "2"); - if (isEditing) { - gridMap.get((int) posEdit).put("themesname", myedittext.getText().toString()); - gridMap.get((int) posEdit).put("themesjson", new Gson().toJson(themes_map)); - gridMap.get((int) posEdit).put("themesinfo", myedittext_info.getText().toString()); - gridMap.get((int) posEdit).put("themesauthor", myedittext_author.getText().toString()); - gridMap.get((int) posEdit).put("os-thm-version", "2"); - data.edit().putString("griddata", new Gson().toJson(gridMap)).commit(); - indexDataList.remove((int) (posEdit)); - indexDataList.add((int) (posEdit), new Gson().toJson(themes_map)); - isPanel = false; - _fab.show(); - vscroll1.setVisibility(View.GONE); - linear_grid.setVisibility(View.VISIBLE); - ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged(); - SketchwareUtil.showMessage(getApplicationContext(), "Saved! "); - } else { - if (indexDataList.contains(new Gson().toJson(themes_map))) { - SketchwareUtil.showMessage(getApplicationContext(), "Same theme scheme detected!"); - } else { - { - HashMap _item = new HashMap<>(); - _item.put("themesname", myedittext.getText().toString()); - gridMap.add(_item); - } - - gridMap.get(gridMap.size() - 1).put("themesjson", new Gson().toJson(themes_map)); - gridMap.get(gridMap.size() - 1).put("themesinfo", myedittext_info.getText().toString()); - gridMap.get(gridMap.size() - 1).put("themesauthor", myedittext_author.getText().toString()); - gridMap.get(gridMap.size() - 1).put("os-thm-version", "2"); - data.edit().putString("griddata", new Gson().toJson(gridMap)).commit(); - indexDataList.add(new Gson().toJson(themes_map)); - isPanel = false; - _fab.show(); - vscroll1.setVisibility(View.GONE); - linear_grid.setVisibility(View.VISIBLE); - ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged(); - SketchwareUtil.showMessage(getApplicationContext(), "Saved! "); - } - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "Name can't empty or contains \"$\"! "); - } - } - }); - dialog2.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - } - }); - dialog2.create().show(); - } - }); - - button1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(1); - } - }); - - button9.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(9); - } - }); - - button2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(2); - } - }); - - sttsbrspin.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { - @Override - public void onItemSelected(AdapterView _param1, View _param2, int _param3, long _param4) { - final int _position = _param3; - _updatePreview(); - } - - @Override - public void onNothingSelected(AdapterView _param1) { - - } - }); - - button3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(3); - } - }); - - button10.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(10); - } - }); - - button4.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(4); - } - }); - - button11.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(11); - } - }); - - sdwchkbx.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton _param1, boolean _param2) { - final boolean _isChecked = _param2; - _updatePreview(); - } - }); - - button5.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(5); - } - }); - - button6.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(6); - } - }); - - button7.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(7); - } - }); - - button8.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(8); - } - }); - - button12.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(12); - } - }); - - button13.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(13); - } - }); - - button14.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(14); - } - }); - - button15.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(15); - } - }); - - button16.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(16); - } - }); - - button17.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _pickColor(17); - } - }); - - _fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - isPanel = true; - isEditing = false; - _fab.hide(); - linear_grid.setVisibility(View.GONE); - vscroll1.setVisibility(View.VISIBLE); - _resetPanel(); - } - }); - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - _shadow(linear_title, 10); - vscroll1.setVisibility(View.GONE); - gridMap = new Gson().fromJson(data.getString("griddata", ""), new TypeToken>>() { - }.getType()); - grid = new GridView(ThemesActivity.this); - - grid.setLayoutParams(new GridView.LayoutParams(GridLayout.LayoutParams.MATCH_PARENT, GridLayout.LayoutParams.WRAP_CONTENT)); - - grid.setNumColumns(GridView.AUTO_FIT); - - grid.setVerticalSpacing(2); - - grid.setHorizontalSpacing(2); - - grid.setColumnWidth((int) SketchwareUtil.getDip(getApplicationContext(), 118)); - - grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); - - linear_grid.addView(grid); - grid.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int _pos, long id) { - _gridSelected(_pos); - } - }); - grid.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView parent, View view, int _pos, long id) { - _gridLongClick(_pos); - return true; - } - }); - grid.setAdapter(new Gridview1Adapter(gridMap)); - for (int _repeat158 = 0; _repeat158 < gridMap.size(); _repeat158++) { - indexDataList.add(gridMap.get(indexDataList.size()).get("themesjson").toString()); - } - spinnerList.add("Black"); - spinnerList.add("White"); - sttsbrspin.setAdapter(new ArrayAdapter(getBaseContext(), android.R.layout.simple_spinner_dropdown_item, spinnerList)); - sttsbrspin.setSelection(1); - dialog_list.add("Delete"); - dialog_list.add("Edit"); - dialog_list.add("More info"); - dialog_list.add("Export theme"); - dialog_list.add("Cancel"); - _customNav("#FFFFFF"); - _circleRipple("#40000000", image_back); - _circleRipple("#40000000", image_import); - text_back.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview18.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview19.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textview20.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview21.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - _setFont(); - } - - private String getHexFromARGB(int _a, int _r, int _g, int _b) { - int alp = _a; - int red = _r; - int grn = _g; - int blu = _b; - if (alp != 255) { - return String.format("%02x%02x%02x%02x", alp, red, grn, blu); - } else { - return String.format("%02x%02x%02x", red, grn, blu); - } - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onBackPressed() { - if (isPanel) { - isPanel = false; - _fab.show(); - vscroll1.setVisibility(View.GONE); - linear_grid.setVisibility(View.VISIBLE); - _resetPanel(); - } else { - finish(); - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - if (!data.getString("tmpPath", "").equals("")) { - tmpPath = data.getString("tmpPath", ""); - data.edit().remove("tmpPath").commit(); - try { - tmpMAPC.clear(); - tmpMAPC = new Gson().fromJson(FileUtil.readFile(tmpPath), new TypeToken>>() { - }.getType()); - double _tmpDouble = 0; - String _testJSON = ""; - for (int _repeat62 = 0; _repeat62 < tmpMAPC.size(); _repeat62++) { - if (tmpMAPC.get((int) _tmpDouble).containsKey("os-thm-version")) { - if (tmpMAPC.get((int) _tmpDouble).get("os-thm-version").toString().equals("2")) { - if (!(tmpMAPC.get((int) _tmpDouble).get("themesname").toString().contains("$") || (tmpMAPC.get((int) _tmpDouble).get("themesname").toString().trim().length() == 0))) { - if (indexDataList.contains(tmpMAPC.get((int) _tmpDouble).get("themesjson").toString())) { - SketchwareUtil.showMessage(getApplicationContext(), "Same theme scheme detected!"); - } else { - tmpMAPJ.clear(); - _testJSON = tmpMAPC.get((int) _tmpDouble).get("themesname").toString(); - _testJSON = tmpMAPC.get((int) _tmpDouble).get("themesauthor").toString(); - _testJSON = tmpMAPC.get((int) _tmpDouble).get("themesinfo").toString(); - tmpMAPJ = new Gson().fromJson(tmpMAPC.get((int) _tmpDouble).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (tmpMAPJ.get(0).containsKey("version")) { - if (tmpMAPJ.get(0).get("version").toString().equals("2")) { - _testJSON = tmpMAPJ.get(0).get("colorPrimary").toString(); - _testJSON = tmpMAPJ.get(0).get("colorPrimaryText").toString(); - _testJSON = tmpMAPJ.get(0).get("colorPrimaryDark").toString(); - _testJSON = tmpMAPJ.get(0).get("statusbarIcon").toString(); - _testJSON = tmpMAPJ.get(0).get("colorBackground").toString(); - _testJSON = tmpMAPJ.get(0).get("colorBackgroundText").toString(); - _testJSON = tmpMAPJ.get(0).get("colorButton").toString(); - _testJSON = tmpMAPJ.get(0).get("colorButtonText").toString(); - _testJSON = tmpMAPJ.get(0).get("shadow").toString(); - _testJSON = tmpMAPJ.get(0).get("colorRipple").toString(); - _testJSON = tmpMAPJ.get(0).get("colorHint").toString(); - _testJSON = tmpMAPJ.get(0).get("colorPrimaryImage").toString(); - _testJSON = tmpMAPJ.get(0).get("colorBackgroundImage").toString(); - _testJSON = tmpMAPJ.get(0).get("colorPrimaryCard").toString(); - _testJSON = tmpMAPJ.get(0).get("colorBackgroundCard").toString(); - _testJSON = tmpMAPJ.get(0).get("colorPrimaryCardText").toString(); - _testJSON = tmpMAPJ.get(0).get("colorBackgroundCardText").toString(); - _testJSON = tmpMAPJ.get(0).get("colorPrimaryCardImage").toString(); - _testJSON = tmpMAPJ.get(0).get("colorBackgroundCardImage").toString(); - tmpMAPM = tmpMAPC.get((int) _tmpDouble); - gridMap.add(tmpMAPM); - data.edit().putString("griddata", new Gson().toJson(gridMap)).commit(); - indexDataList.add(new Gson().toJson(tmpMAPJ)); - ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged(); - if (_tmpDouble == (tmpMAPC.size() - 1)) { - SketchwareUtil.showMessage(getApplicationContext(), "Saved! "); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "Incompatible theme version!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "Incompatible theme version!"); - } - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "Reserved word in theme name detected!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "Incompatible theme version!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "Incompatible theme version!"); - } - _tmpDouble++; - } - } catch (Exception _e) { - showMessage("Invalid theme!"); - } - } - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _pickColor(final double _numberlol) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _colPickView = _inflater.inflate(R.layout.colpick, null); - final TextView text_hastag = _colPickView.findViewById(R.id.text_hastag); - final EditText edit_hex = _colPickView.findViewById(R.id.edit_hex); - final SeekBar seek_a = _colPickView.findViewById(R.id.seek_a); - final SeekBar seek_r = _colPickView.findViewById(R.id.seek_r); - final SeekBar seek_g = _colPickView.findViewById(R.id.seek_g); - final SeekBar seek_b = _colPickView.findViewById(R.id.seek_b); - final TextView text_a = _colPickView.findViewById(R.id.text_a); - final TextView text_r = _colPickView.findViewById(R.id.text_r); - final TextView text_g = _colPickView.findViewById(R.id.text_g); - final TextView text_b = _colPickView.findViewById(R.id.text_b); - final TextView textn_a = _colPickView.findViewById(R.id.textn_a); - final TextView textn_r = _colPickView.findViewById(R.id.textn_r); - final TextView textn_g = _colPickView.findViewById(R.id.textn_g); - final TextView textn_b = _colPickView.findViewById(R.id.textn_b); - final TextView text_plhwarna = _colPickView.findViewById(R.id.text_plhwarna); - final TextView text_axhyre = _colPickView.findViewById(R.id.text_axhyre); - final LinearLayout bg_result = _colPickView.findViewById(R.id.bg_result); - text_hastag.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - edit_hex.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - text_a.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - text_r.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - text_g.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - text_b.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textn_a.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textn_r.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textn_g.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textn_b.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - text_plhwarna.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - text_axhyre.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - try { - String HEX = ""; - if (_numberlol == 1) { - HEX = textview1.getText().toString().toLowerCase(); - } - if (_numberlol == 2) { - HEX = textview2.getText().toString().toLowerCase(); - } - if (_numberlol == 3) { - HEX = textview3.getText().toString().toLowerCase(); - } - if (_numberlol == 4) { - HEX = textview4.getText().toString().toLowerCase(); - } - if (_numberlol == 5) { - HEX = textview5.getText().toString().toLowerCase(); - } - if (_numberlol == 6) { - HEX = textview6.getText().toString().toLowerCase(); - } - if (_numberlol == 7) { - HEX = textview7.getText().toString().toLowerCase(); - } - if (_numberlol == 8) { - HEX = textview8.getText().toString().toLowerCase(); - } - if (_numberlol == 9) { - HEX = textview9.getText().toString().toLowerCase(); - } - if (_numberlol == 10) { - HEX = textview10.getText().toString().toLowerCase(); - } - if (_numberlol == 11) { - HEX = textview11.getText().toString().toLowerCase(); - } - if (_numberlol == 12) { - HEX = textview12.getText().toString().toLowerCase(); - } - if (_numberlol == 13) { - HEX = textview13.getText().toString().toLowerCase(); - } - if (_numberlol == 14) { - HEX = textview14.getText().toString().toLowerCase(); - } - if (_numberlol == 15) { - HEX = textview15.getText().toString().toLowerCase(); - } - if (_numberlol == 16) { - HEX = textview16.getText().toString().toLowerCase(); - } - if (_numberlol == 17) { - HEX = textview17.getText().toString().toLowerCase(); - } - int COLORINT = Color.parseColor(HEX); - edit_hex.setText(HEX.replace("#", "")); - } catch (Exception _e) { - edit_hex.setText("000000"); - } - { - int intColor = Color.parseColor("#" + edit_hex.getText().toString()); - bg_result.setBackgroundColor(intColor); - int a_s = Color.alpha(intColor); - int r_s = Color.red(intColor); - int g_s = Color.green(intColor); - int b_s = Color.blue(intColor); - seek_a.setProgress(a_s); - seek_r.setProgress(r_s); - seek_g.setProgress(g_s); - seek_b.setProgress(b_s); - textn_a.setText(String.valueOf((long) a_s)); - textn_r.setText(String.valueOf((long) r_s)); - textn_g.setText(String.valueOf((long) g_s)); - textn_b.setText(String.valueOf((long) b_s)); - } - - seek_a.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _progressValue, boolean _param3) { - textn_a.setText(String.valueOf((long) _progressValue)); - edit_hex.setText(getHexFromARGB(seek_a.getProgress(), seek_r.getProgress(), seek_g.getProgress(), seek_b.getProgress())); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - } - - @Override - public void onStopTrackingTouch(SeekBar _param1) { - } - }); - seek_r.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _progressValue, boolean _param3) { - textn_r.setText(String.valueOf((long) _progressValue)); - edit_hex.setText(getHexFromARGB(seek_a.getProgress(), seek_r.getProgress(), seek_g.getProgress(), seek_b.getProgress())); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - } - - @Override - public void onStopTrackingTouch(SeekBar _param1) { - } - }); - seek_g.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _progressValue, boolean _param3) { - textn_g.setText(String.valueOf((long) _progressValue)); - edit_hex.setText(getHexFromARGB(seek_a.getProgress(), seek_r.getProgress(), seek_g.getProgress(), seek_b.getProgress())); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - } - - @Override - public void onStopTrackingTouch(SeekBar _param1) { - } - }); - seek_b.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { - @Override - public void onProgressChanged(SeekBar _param1, int _progressValue, boolean _param3) { - textn_b.setText(String.valueOf((long) _progressValue)); - edit_hex.setText(getHexFromARGB(seek_a.getProgress(), seek_r.getProgress(), seek_g.getProgress(), seek_b.getProgress())); - } - - @Override - public void onStartTrackingTouch(SeekBar _param1) { - } - - @Override - public void onStopTrackingTouch(SeekBar _param1) { - } - }); - edit_hex.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - final String _charSeq = _param1.toString(); - try { - int intColor = Color.parseColor("#" + _charSeq); - bg_result.setBackgroundColor(intColor); - int a_s = Color.alpha(intColor); - int r_s = Color.red(intColor); - int g_s = Color.green(intColor); - int b_s = Color.blue(intColor); - seek_a.setProgress(a_s); - seek_r.setProgress(r_s); - seek_g.setProgress(g_s); - seek_b.setProgress(b_s); - } catch (Exception _e) { - } - } - - @Override - public void beforeTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - } - - @Override - public void afterTextChanged(Editable _param1) { - } - }); - colorPicker.setView(_colPickView); - colorPicker.setCancelable(false); - colorPicker.setPositiveButton("Pick", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - try { - int ColorINT = Color.parseColor("#" + edit_hex.getText().toString()); - } catch (Exception _e) { - edit_hex.setText(getHexFromARGB(seek_a.getProgress(), seek_r.getProgress(), seek_g.getProgress(), seek_b.getProgress())); - } - String hexCOLOR = "#" + edit_hex.getText().toString().toUpperCase(); - if (_numberlol == 1) { - textview1.setText(hexCOLOR); - } - if (_numberlol == 2) { - textview2.setText(hexCOLOR); - } - if (_numberlol == 3) { - textview3.setText(hexCOLOR); - } - if (_numberlol == 4) { - textview4.setText(hexCOLOR); - } - if (_numberlol == 5) { - textview5.setText(hexCOLOR); - } - if (_numberlol == 6) { - textview6.setText(hexCOLOR); - } - if (_numberlol == 7) { - textview7.setText(hexCOLOR); - } - if (_numberlol == 8) { - textview8.setText(hexCOLOR); - } - if (_numberlol == 9) { - textview9.setText(hexCOLOR); - } - if (_numberlol == 10) { - textview10.setText(hexCOLOR); - } - if (_numberlol == 11) { - textview11.setText(hexCOLOR); - } - if (_numberlol == 12) { - textview12.setText(hexCOLOR); - } - if (_numberlol == 13) { - textview13.setText(hexCOLOR); - } - if (_numberlol == 14) { - textview14.setText(hexCOLOR); - } - if (_numberlol == 15) { - textview15.setText(hexCOLOR); - } - if (_numberlol == 16) { - textview16.setText(hexCOLOR); - } - if (_numberlol == 17) { - textview17.setText(hexCOLOR); - } - _updatePreview(); - } - }); - colorPicker.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _abandonFocus(); - } - }); - colorPicker.create().show(); - } - - private void _gridSelected(final double _num) { - if (gridMap.get((int) _num).containsKey("os-thm-version")) { - if (gridMap.get((int) _num).get("os-thm-version").toString().equals("2")) { - themes_map.clear(); - themes_map = new Gson().fromJson(gridMap.get((int) _num).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (themes_map.get(0).containsKey("version")) { - if (themes_map.get(0).get("version").toString().equals("2")) { - if (!gridMap.get((int) _num).get("themesjson").toString().equals(data.getString("themesjson", ""))) { - data.edit().putString("themesjson", gridMap.get((int) _num).get("themesjson").toString()).commit(); - SketchwareUtil.showMessage(getApplicationContext(), "Theme Applied! "); - } - } else { - _updateTheme(_num); - } - } else { - _updateTheme(_num); - } - } else { - _updateTheme(_num); - } - } else { - _updateTheme(_num); - } - } - - private void _resetPanel() { - sttsbrspin.setSelection(1); - sdwchkbx.setChecked(true); - textview1.setText("#2196F3"); - textview2.setText("#1769AA"); - textview3.setText("#FFFFFF"); - textview4.setText("#F50057"); - textview5.setText("#40000000"); - textview6.setText("#A8A8A8"); - textview7.setText("#FFFFFF"); - textview8.setText("#2196F3"); - textview9.setText("#FFFFFF"); - textview10.setText("#000000"); - textview11.setText("#FFFFFF"); - textview12.setText("#FFFFFF"); - textview13.setText("#FFFFFF"); - textview14.setText("#000000"); - textview15.setText("#000000"); - textview16.setText("#000000"); - textview17.setText("#000000"); - _updatePreview(); - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - private void _gridLongClick(final double _pos) { - dialog3.setAdapter(new ArrayAdapter(ThemesActivity.this, android.R.layout.simple_list_item_1, dialog_list), new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dia, int _pos_dialog) { - if (_pos_dialog == 0) { - if (gridMap.get((int) _pos).get("themesname").toString().contains("$")) { - SketchwareUtil.showMessage(getApplicationContext(), "Can't edit or delete default theme! "); - } else { - if (gridMap.get((int) _pos).get("themesjson").toString().equals(data.getString("themesjson", ""))) { - SketchwareUtil.showMessage(getApplicationContext(), "Theme is used! "); - } else { - gridMap.remove((int) (_pos)); - indexDataList.remove((int) (_pos)); - data.edit().putString("griddata", new Gson().toJson(gridMap)).commit(); - ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged(); - SketchwareUtil.showMessage(getApplicationContext(), "Deleted! "); - } - } - } else { - if (_pos_dialog == 1) { - if (gridMap.get((int) _pos).get("themesname").toString().contains("$")) { - SketchwareUtil.showMessage(getApplicationContext(), "Can't edit or delete default theme! "); - } else { - if (gridMap.get((int) _pos).get("themesjson").toString().equals(data.getString("themesjson", ""))) { - SketchwareUtil.showMessage(getApplicationContext(), "Theme is used! "); - } else { - _edit(_pos); - } - } - } else { - if (_pos_dialog == 2) { - if (gridMap.get((int) _pos).containsKey("os-thm-version")) { - if (gridMap.get((int) _pos).get("os-thm-version").toString().equals("2")) { - String _tmpStr = ""; - if (gridMap.get((int) _pos).get("themesname").toString().equals("$default_1$")) { - _tmpStr = "Vanilla"; - } else { - if (gridMap.get((int) _pos).get("themesname").toString().equals("$default_2$")) { - _tmpStr = "Dark Mode"; - } else { - _tmpStr = gridMap.get((int) _pos).get("themesname").toString(); - } - } - dialog4.setTitle("Theme metadata"); - dialog4.setMessage("Theme name : ".concat(_tmpStr.concat("\nTheme author : ".concat(gridMap.get((int) _pos).get("themesauthor").toString().concat("\nTheme info : ".concat(gridMap.get((int) _pos).get("themesinfo").toString().concat("\nos-thm-version : ".concat(gridMap.get((int) _pos).get("os-thm-version").toString())))))))); - dialog4.setPositiveButton("Close", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - dialog4.create().show(); - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - if (_pos_dialog == 3) { - if (gridMap.get((int) _pos).containsKey("os-thm-version")) { - if (gridMap.get((int) _pos).get("os-thm-version").toString().equals("2")) { - themes_map.clear(); - themes_map = new Gson().fromJson(gridMap.get((int) _pos).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (themes_map.get(0).containsKey("version")) { - if (themes_map.get(0).get("version").toString().equals("2")) { - tmpMAPC.clear(); - tmpMAPM = gridMap.get((int) _pos); - tmpMAPC.add(tmpMAPM); - FileUtil.writeFile(FileUtil.getExternalStorageDir().concat("/os-thm/".concat(gridMap.get((int) _pos).get("themesname").toString().replace("/", "_").concat(".os-thm"))), new Gson().toJson(tmpMAPC)); - SketchwareUtil.showMessage(getApplicationContext(), "Exported in ".concat(FileUtil.getExternalStorageDir().concat("/os-thm/".concat(gridMap.get((int) _pos).get("themesname").toString().replace("/", "_").concat(".os-thm"))))); - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - - } - } - } - } - } - }); - dialog3.create().show(); - } - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - private void _updatePreview() { - if (sttsbrspin.getSelectedItemPosition() == 1) { - imageview3.setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY); - imageview4.setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY); - imageview5.setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY); - imageview6.setColorFilter(0xFFFFFFFF, PorterDuff.Mode.MULTIPLY); - textview21.setTextColor(0xFFFFFFFF); - } else { - imageview3.setColorFilter(0xFF000000, PorterDuff.Mode.MULTIPLY); - imageview4.setColorFilter(0xFF000000, PorterDuff.Mode.MULTIPLY); - imageview5.setColorFilter(0xFF000000, PorterDuff.Mode.MULTIPLY); - imageview6.setColorFilter(0xFF000000, PorterDuff.Mode.MULTIPLY); - textview21.setTextColor(0xFF000000); - } - _shape(SketchwareUtil.getDip(getApplicationContext(), 25), SketchwareUtil.getDip(getApplicationContext(), 25), SketchwareUtil.getDip(getApplicationContext(), 25), SketchwareUtil.getDip(getApplicationContext(), 25), textview4.getText().toString(), "#FFFFFF", 0, imageview2); - imageview1.setColorFilter(Color.parseColor(textview7.getText().toString()), PorterDuff.Mode.MULTIPLY); - imageview2.setColorFilter(Color.parseColor(textview11.getText().toString()), PorterDuff.Mode.MULTIPLY); - textview18.setTextColor(Color.parseColor(textview9.getText().toString())); - textview19.setTextColor(Color.parseColor(textview9.getText().toString())); - textview20.setTextColor(Color.parseColor(textview10.getText().toString())); - linear18.setBackgroundColor(Color.parseColor(textview2.getText().toString())); - linear16.setBackgroundColor(Color.parseColor(textview1.getText().toString())); - linear15.setBackgroundColor(Color.parseColor(textview3.getText().toString())); - if (sdwchkbx.isChecked()) { - _shadow(linear16, 10); - _shadow(imageview2, 10); - } else { - _shadow(linear16, 0); - _shadow(imageview2, 0); - } - } - - private void _edit(final double _position) { - if (gridMap.get((int) _position).containsKey("os-thm-version")) { - if (gridMap.get((int) _position).get("os-thm-version").toString().equals("2")) { - themes_map.clear(); - themes_map = new Gson().fromJson(gridMap.get((int) _position).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (themes_map.get(0).containsKey("version")) { - if (themes_map.get(0).get("version").toString().equals("2")) { - isPanel = true; - _fab.hide(); - linear_grid.setVisibility(View.GONE); - vscroll1.setVisibility(View.VISIBLE); - isEditing = true; - posEdit = _position; - textview1.setText(themes_map.get(0).get("colorPrimary").toString()); - textview9.setText(themes_map.get(0).get("colorPrimaryText").toString()); - textview2.setText(themes_map.get(0).get("colorPrimaryDark").toString()); - sttsbrspin.setSelection((int) (Double.parseDouble(themes_map.get(0).get("statusbarIcon").toString()))); - textview3.setText(themes_map.get(0).get("colorBackground").toString()); - textview10.setText(themes_map.get(0).get("colorBackgroundText").toString()); - textview4.setText(themes_map.get(0).get("colorButton").toString()); - textview11.setText(themes_map.get(0).get("colorButtonText").toString()); - if (themes_map.get(0).get("shadow").toString().equals("1")) { - sdwchkbx.setChecked(true); - } else { - sdwchkbx.setChecked(false); - } - textview5.setText(themes_map.get(0).get("colorRipple").toString()); - textview6.setText(themes_map.get(0).get("colorHint").toString()); - textview7.setText(themes_map.get(0).get("colorPrimaryImage").toString()); - textview8.setText(themes_map.get(0).get("colorBackgroundImage").toString()); - textview12.setText(themes_map.get(0).get("colorPrimaryCard").toString()); - textview13.setText(themes_map.get(0).get("colorBackgroundCard").toString()); - textview14.setText(themes_map.get(0).get("colorPrimaryCardText").toString()); - textview15.setText(themes_map.get(0).get("colorBackgroundCardText").toString()); - textview16.setText(themes_map.get(0).get("colorPrimaryCardImage").toString()); - textview17.setText(themes_map.get(0).get("colorBackgroundCardImage").toString()); - _updatePreview(); - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } else { - SketchwareUtil.showMessage(getApplicationContext(), "This theme version isn't compatible with the current theme engine!"); - } - } - - private void _updateTheme(final double _position) { - _resetPanel(); - themes_map.clear(); - themes_map = new Gson().fromJson(gridMap.get((int) _position).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - isPanel = true; - _fab.hide(); - linear_grid.setVisibility(View.GONE); - vscroll1.setVisibility(View.VISIBLE); - isEditing = true; - posEdit = _position; - if (themes_map.get(0).containsKey("colorPrimary")) { - textview1.setText(themes_map.get(0).get("colorPrimary").toString()); - } - if (themes_map.get(0).containsKey("colorPrimaryDark")) { - textview2.setText(themes_map.get(0).get("colorPrimaryDark").toString()); - } - if (themes_map.get(0).containsKey("statusbarIcon")) { - sttsbrspin.setSelection((int) (Double.parseDouble(themes_map.get(0).get("statusbarIcon").toString()))); - } - if (themes_map.get(0).containsKey("colorBackground")) { - textview3.setText(themes_map.get(0).get("colorBackground").toString()); - } - if (themes_map.get(0).containsKey("colorButton")) { - textview4.setText(themes_map.get(0).get("colorButton").toString()); - } - if (themes_map.get(0).containsKey("shadow")) { - if (themes_map.get(0).get("shadow").toString().equals("1")) { - sdwchkbx.setChecked(true); - } else { - sdwchkbx.setChecked(false); - } - } - if (themes_map.get(0).containsKey("colorRipple")) { - textview5.setText(themes_map.get(0).get("colorRipple").toString()); - } - if (themes_map.get(0).containsKey("colorHint")) { - textview6.setText(themes_map.get(0).get("colorHint").toString()); - } - if (themes_map.get(0).containsKey("colorPrimaryImage")) { - textview7.setText(themes_map.get(0).get("colorPrimaryImage").toString()); - } - if (themes_map.get(0).containsKey("colorBackgroundImage")) { - textview8.setText(themes_map.get(0).get("colorBackgroundImage").toString()); - } - if (themes_map.get(0).containsKey("colorPrimaryCard")) { - textview12.setText(themes_map.get(0).get("colorPrimaryCard").toString()); - } - if (themes_map.get(0).containsKey("colorBackgroundCard")) { - textview13.setText(themes_map.get(0).get("colorBackgroundCard").toString()); - } - if (themes_map.get(0).containsKey("colorPrimaryCardText")) { - textview14.setText(themes_map.get(0).get("colorPrimaryCardText").toString()); - } - if (themes_map.get(0).containsKey("colorBackgroundCardText")) { - textview15.setText(themes_map.get(0).get("colorBackgroundCardText").toString()); - } - if (themes_map.get(0).containsKey("colorPrimaryCardImage")) { - textview16.setText(themes_map.get(0).get("colorPrimaryCardImage").toString()); - } - if (themes_map.get(0).containsKey("colorBackgroundCardImage")) { - textview17.setText(themes_map.get(0).get("colorBackgroundCardImage").toString()); - } - if (themes_map.get(0).containsKey("version")) { - if (themes_map.get(0).containsKey("colorPrimaryText")) { - textview9.setText(themes_map.get(0).get("colorPrimaryText").toString()); - } - if (themes_map.get(0).containsKey("colorBackgroundText")) { - textview10.setText(themes_map.get(0).get("colorBackgroundText").toString()); - } - if (themes_map.get(0).containsKey("colorButtonText")) { - textview11.setText(themes_map.get(0).get("colorButtonText").toString()); - } - } else { - if (themes_map.get(0).containsKey("colorPrimaryText")) { - if (themes_map.get(0).get("colorPrimaryText").toString().equals("1")) { - textview9.setText("#FFFFFF"); - } else { - textview9.setText("#000000"); - } - } - if (themes_map.get(0).containsKey("colorBackgroundText")) { - if (themes_map.get(0).get("colorBackgroundText").toString().equals("1")) { - textview10.setText("#FFFFFF"); - } else { - textview10.setText("#000000"); - } - } - if (themes_map.get(0).containsKey("colorButtonText")) { - if (themes_map.get(0).get("colorButtonText").toString().equals("1")) { - textview11.setText("#FFFFFF"); - } else { - textview11.setText("#000000"); - } - } - } - _updatePreview(); - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private void _abandonFocus() { - View _tmpView = this.getCurrentFocus(); - if (_tmpView != null) { - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(_tmpView.getWindowToken(), 0); - } - } - - private void _setFont() { - colprimtext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colprimtxttext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colprimdarktext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - sttsbrtext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbgtext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbgtxttext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbttntext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbttntxttext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - sdwtext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colriptext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colhnttext.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colprimimgtxt.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbgimgtxt.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colprimcrd.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbgcrd.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colprimcrdtxt.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbgcrdtxt.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colprimcrdimg.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - colbgcrdimg.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - sdwchkbx.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button5.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button6.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button7.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button8.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button9.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button10.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button11.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button12.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button13.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button14.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button15.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button16.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button17.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview5.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview6.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview7.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview8.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview9.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview10.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview11.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview12.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview13.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview14.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview15.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview16.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview17.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public class Gridview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Gridview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.theme_preview, null); - } - - final ImageView imageview_plus = _v.findViewById(R.id.imageview_plus); - final ImageView imageview_back = _v.findViewById(R.id.imageview_back); - final TextView textview_title = _v.findViewById(R.id.textview_title); - final TextView textview_name = _v.findViewById(R.id.textview_name); - final LinearLayout linear_title = _v.findViewById(R.id.linear_title); - final LinearLayout linear_base = _v.findViewById(R.id.linear_base); - - textview_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - - textview_name.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - - if (gridMap.get(_position).get("themesname").toString().equals("$default_1$")) { - textview_name.setText("Vanilla"); - } else { - if (gridMap.get(_position).get("themesname").toString().equals("$default_2$")) { - textview_name.setText("Dark Mode"); - } else { - textview_name.setText(gridMap.get(_position).get("themesname").toString()); - } - } - gridtmp = new Gson().fromJson(gridMap.get(_position).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (!gridtmp.get(0).containsKey("version")) { - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor("#F50057")); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - _shape(8, 8, 0, 0, "#2196F3", "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, "#FAFAFA", "#FFFFFF", 0, linear_base); - linear_title.setElevation(10); - linear_base.setElevation(10); - } else { - if (!gridtmp.get(0).get("version").toString().equals("2")) { - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor("#F50057")); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - _shape(8, 8, 0, 0, "#2196F3", "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, "#FAFAFA", "#FFFFFF", 0, linear_base); - linear_title.setElevation(10); - linear_base.setElevation(10); - } else { - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor(gridtmp.get(0).get("colorButton").toString())); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - linear_base.setElevation(10); - if (gridtmp.get(0).get("shadow").toString().equals("1")) - linear_title.setElevation(10); - else - linear_title.setElevation(0); - imageview_back.setColorFilter(Color.parseColor(gridtmp.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_plus.setColorFilter(Color.parseColor(gridtmp.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - textview_title.setTextColor(Color.parseColor(gridtmp.get(0).get("colorPrimaryText").toString())); - textview_name.setTextColor(Color.parseColor(gridtmp.get(0).get("colorBackgroundText").toString())); - _shape(8, 8, 0, 0, gridtmp.get(0).get("colorPrimary").toString(), "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, gridtmp.get(0).get("colorBackground").toString(), "#FFFFFF", 0, linear_base); - } - } - - return _v; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/ThemesstrActivity.java b/app/src/main/java/tw/music/streamer/ThemesstrActivity.java deleted file mode 100644 index 0d46a78..0000000 --- a/app/src/main/java/tw/music/streamer/ThemesstrActivity.java +++ /dev/null @@ -1,879 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.os.Build; -import android.os.Bundle; -import android.text.TextUtils; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.AbsListView; -import android.widget.AdapterView; -import android.widget.BaseAdapter; -import android.widget.GridLayout; -import android.widget.GridView; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.database.ValueEventListener; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -public class ThemesstrActivity extends AppCompatActivity { - - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - - private FloatingActionButton _fab; - private boolean isOpened = false; - private HashMap map_var = new HashMap<>(); - private boolean isAdmin = false; - private double num = 0; - private HashMap tmpMap = new HashMap<>(); - - private ArrayList> fb_listmap = new ArrayList<>(); - private ArrayList childKey = new ArrayList<>(); - private ArrayList> themes_map = new ArrayList<>(); - private ArrayList> gridMap = new ArrayList<>(); - private ArrayList> gridtmp = new ArrayList<>(); - private ArrayList adminsList = new ArrayList<>(); - private ArrayList> profile_map = new ArrayList<>(); - private ArrayList proChildKeys = new ArrayList<>(); - private ArrayList indexTheme = new ArrayList<>(); - private ArrayList indexThmStr = new ArrayList<>(); - private ArrayList> theme_map = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private ImageView imageview1; - private TextView textview1; - private ListView listview1; - private LinearLayout linear_grid; - - private DatabaseReference fb_themes = _firebase.getReference("upload/themes"); - private ChildEventListener _fb_themes_child_listener; - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private DatabaseReference profile = _firebase.getReference("profile/text"); - private ChildEventListener _profile_child_listener; - private DatabaseReference profile_admins = _firebase.getReference("profile/admins"); - private ChildEventListener _profile_admins_child_listener; - private AlertDialog.Builder d; - private SharedPreferences data; - private GridView grid; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.themesstr); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - _fab = findViewById(R.id._fab); - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - imageview1 = findViewById(R.id.imageview1); - textview1 = findViewById(R.id.textview1); - listview1 = findViewById(R.id.listview1); - linear_grid = findViewById(R.id.linear_grid); - Auth = FirebaseAuth.getInstance(); - d = new AlertDialog.Builder(this); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isOpened) { - isOpened = false; - _fab.show(); - listview1.setVisibility(View.VISIBLE); - linear_grid.setVisibility(View.GONE); - textview1.setText("Themes Store"); - } else { - finish(); - } - } - }); - - listview1.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView _param1, View _param2, int _param3, long _param4) { - final int _position = _param3; - d.setCancelable(false); - d.setTitle("Download theme"); - d.setMessage("Do you want to download \"".concat(fb_listmap.get(_position).get("themesname").toString().concat("\" theme scheme?"))); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - if (indexTheme.contains(fb_listmap.get(_position).get("themesjson").toString())) { - _customSnack("Duplicate theme scheme detected!", 2); - } else { - tmpMap = new HashMap<>(); - tmpMap = fb_listmap.get(_position); - tmpMap.remove("uid"); - gridMap.add(tmpMap); - data.edit().putString("griddata", new Gson().toJson(gridMap)).commit(); - ((BaseAdapter) grid.getAdapter()).notifyDataSetChanged(); - indexTheme.add(fb_listmap.get(_position).get("themesjson").toString()); - _customSnack("Successfully added!", 1); - } - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - d.create().show(); - } - }); - - listview1.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { - @Override - public boolean onItemLongClick(AdapterView _param1, View _param2, int _param3, long _param4) { - final int _position = _param3; - if (fb_listmap.get(_position).get("uid").toString().equals(FirebaseAuth.getInstance().getCurrentUser().getUid()) || isAdmin) { - d.setCancelable(false); - d.setTitle("Delete"); - d.setMessage("Do you want to delete \"".concat(fb_listmap.get(_position).get("themesname").toString().concat("\" theme scheme?"))); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - fb_themes.child(childKey.get(_position)).removeValue(); - _customSnack("Delete success!", 1); - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - d.create().show(); - } else { - _customSnack("Access denied!", 2); - } - return true; - } - }); - - _fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _fab.hide(); - isOpened = true; - listview1.setVisibility(View.GONE); - linear_grid.setVisibility(View.VISIBLE); - textview1.setText("Pick themes"); - } - }); - - _fb_themes_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - childKey.add(_childKey); - indexThmStr.add(_childValue.get("themesjson").toString()); - fb_listmap.add(_childValue); - listview1.setAdapter(new Listview1Adapter(fb_listmap)); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - fb_listmap.remove(childKey.indexOf(_childKey)); - childKey.remove(childKey.indexOf(_childKey)); - indexThmStr.remove(indexThmStr.indexOf(_childValue.get("themesjson").toString())); - listview1.setAdapter(new Listview1Adapter(fb_listmap)); - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - fb_themes.addChildEventListener(_fb_themes_child_listener); - - _profile_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - proChildKeys.add(_childKey); - profile_map.add(_childValue); - listview1.setAdapter(new Listview1Adapter(fb_listmap)); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - profile.addListenerForSingleValueEvent(new ValueEventListener() { - @Override - public void onDataChange(DataSnapshot _dataSnapshot) { - profile_map = new ArrayList<>(); - try { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - for (DataSnapshot _data : _dataSnapshot.getChildren()) { - HashMap _map = _data.getValue(_ind); - profile_map.add(_map); - } - } catch (Exception _e) { - _e.printStackTrace(); - } - listview1.setAdapter(new Listview1Adapter(fb_listmap)); - } - - @Override - public void onCancelled(DatabaseError _databaseError) { - } - }); - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile.addChildEventListener(_profile_child_listener); - - _profile_admins_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - adminsList.add(_childKey); - if (_childKey.equals(FirebaseAuth.getInstance().getCurrentUser().getUid())) { - isAdmin = true; - } - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - profile_admins.addChildEventListener(_profile_admins_child_listener); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - _loadTheme(); - gridMap = new Gson().fromJson(data.getString("griddata", ""), new TypeToken>>() { - }.getType()); - for (int _repeat27 = 0; _repeat27 < gridMap.size(); _repeat27++) { - indexTheme.add(gridMap.get(indexTheme.size()).get("themesjson").toString()); - } - grid = new GridView(ThemesstrActivity.this); - - grid.setLayoutParams(new GridView.LayoutParams(GridLayout.LayoutParams.MATCH_PARENT, GridLayout.LayoutParams.MATCH_PARENT)); - - grid.setNumColumns(GridView.AUTO_FIT); - - grid.setVerticalSpacing(2); - - grid.setHorizontalSpacing(2); - - grid.setColumnWidth((int) SketchwareUtil.getDip(getApplicationContext(), 118)); - - grid.setStretchMode(GridView.STRETCH_COLUMN_WIDTH); - - linear_grid.addView(grid); - grid.setOnItemClickListener(new AdapterView.OnItemClickListener() { - @Override - public void onItemClick(AdapterView parent, View view, int _pos, long id) { - _gridSelected(_pos); - } - }); - grid.setAdapter(new Gridview1Adapter(gridMap)); - linear_grid.setVisibility(View.GONE); - listview1.setOnScrollListener(new android.widget.AbsListView.OnScrollListener() { - @Override - public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { - - _ScrollCheck(); - - } - - - public void onScrollStateChanged(AbsListView view, int scrollState) { // TODO Auto-generated method stub - _ScrollCheck(); - } - }); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onBackPressed() { - if (isOpened) { - isOpened = false; - _fab.show(); - listview1.setVisibility(View.VISIBLE); - linear_grid.setVisibility(View.GONE); - textview1.setText("Themes Store"); - } else { - finish(); - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - private void _gridSelected(final double _num) { - if (gridMap.get((int) _num).get("themesname").toString().contains("$")) { - _customSnack("Can't upload default theme scheme!", 2); - } else { - if (gridMap.get((int) _num).containsKey("os-thm-version")) { - if (gridMap.get((int) _num).get("os-thm-version").toString().equals("2")) { - themes_map.clear(); - themes_map = new Gson().fromJson(gridMap.get((int) _num).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (themes_map.get(0).containsKey("version")) { - if (themes_map.get(0).get("version").toString().equals("2")) { - d.setCancelable(false); - d.setTitle("Upload theme"); - d.setMessage("Are you sure to upload \"".concat(gridMap.get((int) _num).get("themesname").toString().concat("\" theme scheme?"))); - d.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - if (indexThmStr.contains(gridMap.get((int) _num).get("themesjson").toString())) { - _customSnack("Duplicate theme scheme detected!", 2); - } else { - map_var = new HashMap<>(); - map_var = gridMap.get((int) _num); - map_var.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - fb_themes.push().updateChildren(map_var); - _customSnack("Successfully uploaded!", 1); - } - } - }); - d.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - d.create().show(); - } else { - _customSnack("Unsupported theme version!", 2); - } - } else { - _customSnack("Unsupported theme version!", 2); - } - } else { - _customSnack("Unsupported theme version!", 2); - } - } else { - _customSnack("Unsupported theme version!", 2); - } - } - } - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _ScrollCheck() { - if (listview1.getFirstVisiblePosition() == 0 && listview1.getTop() >= 0) { - _fab.show(); - } else { - _fab.hide(); - } - } - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), imageview1); - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - linear_grid.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - _fab.setBackgroundTintList(android.content.res.ColorStateList.valueOf(Color.parseColor(theme_map.get(0).get("colorButton").toString()))); - _fab.setRippleColor(Color.parseColor(theme_map.get(0).get("colorRipple").toString())); - textview1.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - _fab.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString())); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public class Gridview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Gridview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.theme_preview, null); - } - - final ImageView imageview_plus = _v.findViewById(R.id.imageview_plus); - final ImageView imageview_back = _v.findViewById(R.id.imageview_back); - final TextView textview_title = _v.findViewById(R.id.textview_title); - final TextView textview_name = _v.findViewById(R.id.textview_name); - final LinearLayout linear_title = _v.findViewById(R.id.linear_title); - final LinearLayout linear_base = _v.findViewById(R.id.linear_base); - - textview_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - - textview_name.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - - if (gridMap.get(_position).get("themesname").toString().equals("$default_1$")) { - textview_name.setText("Vanilla"); - } else { - if (gridMap.get(_position).get("themesname").toString().equals("$default_2$")) { - textview_name.setText("Dark Mode"); - } else { - textview_name.setText(gridMap.get(_position).get("themesname").toString()); - } - } - gridtmp = new Gson().fromJson(gridMap.get(_position).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - if (!gridtmp.get(0).containsKey("version")) { - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor("#F50057")); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - _shape(8, 8, 0, 0, "#2196F3", "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, "#FAFAFA", "#FFFFFF", 0, linear_base); - linear_title.setElevation(10); - linear_base.setElevation(10); - } else { - if (!gridtmp.get(0).get("version").toString().equals("2")) { - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor("#F50057")); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - _shape(8, 8, 0, 0, "#2196F3", "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, "#FAFAFA", "#FFFFFF", 0, linear_base); - linear_title.setElevation(10); - linear_base.setElevation(10); - } else { - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor(gridtmp.get(0).get("colorButton").toString())); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - linear_base.setElevation(10); - if (gridtmp.get(0).get("shadow").toString().equals("1")) - linear_title.setElevation(10); - else - linear_title.setElevation(0); - imageview_back.setColorFilter(Color.parseColor(gridtmp.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_plus.setColorFilter(Color.parseColor(gridtmp.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - textview_title.setTextColor(Color.parseColor(gridtmp.get(0).get("colorPrimaryText").toString())); - textview_name.setTextColor(Color.parseColor(gridtmp.get(0).get("colorBackgroundText").toString())); - _shape(8, 8, 0, 0, gridtmp.get(0).get("colorPrimary").toString(), "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, gridtmp.get(0).get("colorBackground").toString(), "#FFFFFF", 0, linear_base); - } - } - - return _v; - } - } - - public class Listview1Adapter extends BaseAdapter { - ArrayList> _data; - - public Listview1Adapter(ArrayList> _arr) { - _data = _arr; - } - - @Override - public int getCount() { - return _data.size(); - } - - @Override - public HashMap getItem(int _index) { - return _data.get(_index); - } - - @Override - public long getItemId(int _index) { - return _index; - } - - @Override - public View getView(final int _position, View _view, ViewGroup _viewGroup) { - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _v = _view; - if (_v == null) { - _v = _inflater.inflate(R.layout.themes_store_list, null); - } - - final LinearLayout linear1 = _v.findViewById(R.id.linear1); - final LinearLayout linear_base = _v.findViewById(R.id.linear_base); - final LinearLayout linear5 = _v.findViewById(R.id.linear5); - final LinearLayout linear_title = _v.findViewById(R.id.linear_title); - final LinearLayout linear_gravity = _v.findViewById(R.id.linear_gravity); - final ImageView imageview_plus = _v.findViewById(R.id.imageview_plus); - final ImageView imageview_back = _v.findViewById(R.id.imageview_back); - final TextView textview_title = _v.findViewById(R.id.textview_title); - final TextView textview_name = _v.findViewById(R.id.textview_name); - final TextView textview_uploader = _v.findViewById(R.id.textview_uploader); - - try { - themes_map.clear(); - textview_name.setText(fb_listmap.get(_position).get("themesname").toString()); - if (proChildKeys.contains(fb_listmap.get(_position).get("uid").toString())) { - textview_uploader.setText(profile_map.get(proChildKeys.indexOf(fb_listmap.get(_position).get("uid").toString())).get("username").toString()); - } else { - textview_uploader.setText(fb_listmap.get(_position).get("uid").toString()); - } - themes_map = new Gson().fromJson(fb_listmap.get(_position).get("themesjson").toString(), new TypeToken>>() { - }.getType()); - android.graphics.drawable.GradientDrawable gd = new android.graphics.drawable.GradientDrawable(); - gd.setColor(Color.parseColor(themes_map.get(0).get("colorButton").toString())); - gd.setCornerRadius(50); - imageview_plus.setBackground(gd); - imageview_plus.setElevation(10); - linear_base.setElevation(10); - if (themes_map.get(0).get("shadow").toString().equals("1")) - linear_title.setElevation(10); - else - linear_title.setElevation(0); - imageview_back.setColorFilter(Color.parseColor(themes_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - imageview_plus.setColorFilter(Color.parseColor(themes_map.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - textview_title.setTextColor(Color.parseColor(themes_map.get(0).get("colorPrimaryText").toString())); - _shape(8, 8, 0, 0, themes_map.get(0).get("colorPrimary").toString(), "#FFFFFF", 0, linear_title); - _shape(8, 8, 8, 8, themes_map.get(0).get("colorBackground").toString(), "#FFFFFF", 0, linear_base); - textview_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_name.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_uploader.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_title.setEllipsize(TextUtils.TruncateAt.END); - textview_name.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - if (adminsList.contains(fb_listmap.get(_position).get("uid").toString())) { - textview_uploader.setTextColor(Color.parseColor(theme_map.get(0).get("colorButton").toString())); - } else { - textview_uploader.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundText").toString())); - } - } catch (Exception _e) { - } - - return _v; - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/UpdateAppActivity.java b/app/src/main/java/tw/music/streamer/UpdateAppActivity.java new file mode 100644 index 0000000..4e016d6 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/UpdateAppActivity.java @@ -0,0 +1,15 @@ +package tw.music.streamer; + +import android.content.Context; +import android.os.Bundle; + +import androidx.appcompat.app.AppCompatActivity; + +public class UpdateAppActivity extends AppCompatActivity { + + @Override + protected void onCreate(Bundle a) { + super.onCreate(a); + } + +} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/UpdateappActivity.java b/app/src/main/java/tw/music/streamer/UpdateappActivity.java deleted file mode 100644 index bd14dd4..0000000 --- a/app/src/main/java/tw/music/streamer/UpdateappActivity.java +++ /dev/null @@ -1,523 +0,0 @@ -package tw.music.streamer; - -import android.content.Intent; -import android.graphics.Color; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.view.Window; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Random; - -public class UpdateappActivity extends AppCompatActivity { - - - private HashMap mapVar = new HashMap<>(); - private boolean isShown = false; - - private LinearLayout linear5; - private ScrollView vscroll1; - private LinearLayout linear4; - private ImageView imageview3; - private TextView textview9; - private LinearLayout linear1; - private TextView textview1; - private TextView textview2; - private TextView textview7; - private TextView textview6; - private TextView textview3; - private LinearLayout linear2; - private LinearLayout linear3; - private LinearLayout linear6; - private ImageView imageview1; - private TextView textview4; - private ImageView imageview2; - private TextView textview5; - private ImageView imageview4; - private TextView textview10; - private TextView textview8; - - private Intent intent = new Intent(); - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.updateapp); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - linear5 = findViewById(R.id.linear5); - vscroll1 = findViewById(R.id.vscroll1); - linear4 = findViewById(R.id.linear4); - imageview3 = findViewById(R.id.imageview3); - textview9 = findViewById(R.id.textview9); - linear1 = findViewById(R.id.linear1); - textview1 = findViewById(R.id.textview1); - textview2 = findViewById(R.id.textview2); - textview7 = findViewById(R.id.textview7); - textview6 = findViewById(R.id.textview6); - textview3 = findViewById(R.id.textview3); - linear2 = findViewById(R.id.linear2); - linear3 = findViewById(R.id.linear3); - linear6 = findViewById(R.id.linear6); - imageview1 = findViewById(R.id.imageview1); - textview4 = findViewById(R.id.textview4); - imageview2 = findViewById(R.id.imageview2); - textview5 = findViewById(R.id.textview5); - imageview4 = findViewById(R.id.imageview4); - textview10 = findViewById(R.id.textview10); - textview8 = findViewById(R.id.textview8); - - textview6.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isShown) { - isShown = false; - textview7.setVisibility(View.GONE); - textview6.setText("Read more"); - } else { - isShown = true; - textview7.setVisibility(View.VISIBLE); - textview6.setText("Read less"); - } - } - }); - - linear2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setData(Uri.parse(mapVar.get("url").toString())); - intent.setAction(Intent.ACTION_VIEW); - startActivity(intent); - } - }); - - linear3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setData(Uri.parse(mapVar.get("sketchub").toString())); - intent.setAction(Intent.ACTION_VIEW); - startActivity(intent); - } - }); - - linear6.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setData(Uri.parse(mapVar.get("teammusic").toString())); - intent.setAction(Intent.ACTION_VIEW); - startActivity(intent); - } - }); - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - mapVar = new Gson().fromJson(getIntent().getStringExtra("updateData"), new TypeToken>() { - }.getType()); - textview8.setText(mapVar.get("versionName").toString()); - if (mapVar.get("closed").toString().equals("1")) { - textview1.setText(mapVar.get("closed-header-title").toString()); - textview2.setText(mapVar.get("closed-header-msg").toString()); - linear2.setVisibility(View.GONE); - linear3.setVisibility(View.GONE); - linear6.setVisibility(View.GONE); - textview3.setVisibility(View.GONE); - textview9.setText(mapVar.get("closed-title").toString()); - textview7.setText(mapVar.get("closed-msg").toString()); - imageview3.setImageResource(R.drawable.ic_exit_white); - } else { - textview1.setText(mapVar.get("header-title").toString()); - textview2.setText(mapVar.get("header-msg").toString()); - textview9.setText(mapVar.get("title").toString()); - textview7.setText(mapVar.get("msg").toString()); - } - textview7.setVisibility(View.GONE); - linear4.setTranslationY(SketchwareUtil.getDip(getApplicationContext(), -150)); - textview1.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview2.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview3.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview4.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview5.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview6.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview7.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview8.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesansbold.ttf"), 0); - textview9.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview10.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - _shadow(linear5, 10); - _circleRipple("#40000000", imageview3); - _rippleEffect(linear2, "#40000000"); - _rippleEffect(linear3, "#40000000"); - _rippleEffect(linear6, "#40000000"); - } - - public void drawableclass() { - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onStart() { - super.onStart(); - _DarkMode(); - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - private void _rippleEffect(final View _view, final String _color) { - _view.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(_color))); - _view.setClickable(true); - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - private void _DarkMode() { - int nightModeFlags = getResources().getConfiguration().uiMode & android.content.res.Configuration.UI_MODE_NIGHT_MASK; - if (nightModeFlags == android.content.res.Configuration.UI_MODE_NIGHT_YES) { - vscroll1.setBackgroundColor(0xFF252525); - textview1.setTextColor(0xFFFFFFFF); - textview7.setTextColor(0xFFFFFFFF); - textview3.setTextColor(0xFFFFFFFF); - textview4.setTextColor(0xFFFFFFFF); - textview5.setTextColor(0xFFFFFFFF); - textview10.setTextColor(0xFFFFFFFF); - _customNav("#252525"); - } else { - vscroll1.setBackgroundColor(0xFFFFFFFF); - textview1.setTextColor(0xFF000000); - textview7.setTextColor(0xFF000000); - textview3.setTextColor(0xFF000000); - textview4.setTextColor(0xFF000000); - textview5.setTextColor(0xFF000000); - textview10.setTextColor(0xFF000000); - _customNav("#FFFFFF"); - } - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/UploadActivity.java b/app/src/main/java/tw/music/streamer/UploadActivity.java deleted file mode 100644 index 320726e..0000000 --- a/app/src/main/java/tw/music/streamer/UploadActivity.java +++ /dev/null @@ -1,700 +0,0 @@ -package tw.music.streamer; - -import android.Manifest; -import android.app.Activity; -import android.app.AlertDialog; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.PorterDuff; -import android.graphics.PorterDuffXfermode; -import android.graphics.Rect; -import android.graphics.RectF; -import android.graphics.Typeface; -import android.media.MediaMetadataRetriever; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.widget.Button; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ProgressBar; -import android.widget.TextView; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.content.ContextCompat; - -import com.google.android.gms.tasks.Continuation; -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.OnFailureListener; -import com.google.android.gms.tasks.OnSuccessListener; -import com.google.android.gms.tasks.Task; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; -import com.google.firebase.database.ChildEventListener; -import com.google.firebase.database.DataSnapshot; -import com.google.firebase.database.DatabaseError; -import com.google.firebase.database.DatabaseReference; -import com.google.firebase.database.FirebaseDatabase; -import com.google.firebase.database.GenericTypeIndicator; -import com.google.firebase.storage.FileDownloadTask; -import com.google.firebase.storage.FirebaseStorage; -import com.google.firebase.storage.OnProgressListener; -import com.google.firebase.storage.StorageReference; -import com.google.firebase.storage.UploadTask; -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Random; - -public class UploadActivity extends AppCompatActivity { - - private FirebaseDatabase _firebase = FirebaseDatabase.getInstance(); - private FirebaseStorage _firebase_storage = FirebaseStorage.getInstance(); - - private String path = ""; - private String name = ""; - private HashMap upload_map = new HashMap<>(); - private boolean isExitDisabled = false; - private String img_path = ""; - private String tmpurl = ""; - - private ArrayList> theme_map = new ArrayList<>(); - private ArrayList indexName = new ArrayList<>(); - - private LinearLayout linear1; - private LinearLayout linear2; - private ImageView image_back; - private TextView textview_title; - private LinearLayout linear7; - private LinearLayout linear5; - private LinearLayout linear4; - private EditText edittext_name; - private Button button_upload; - private TextView textview_path; - private ImageView imageview1; - private TextView textview_upload; - private TextView textview_prog; - private ProgressBar progressbar1; - - private StorageReference upload_storage = _firebase_storage.getReference("upload/music"); - private OnCompleteListener _upload_storage_upload_success_listener; - private OnSuccessListener _upload_storage_download_success_listener; - private OnSuccessListener _upload_storage_delete_success_listener; - private OnProgressListener _upload_storage_upload_progress_listener; - private OnProgressListener _upload_storage_download_progress_listener; - private OnFailureListener _upload_storage_failure_listener; - private DatabaseReference upload_text = _firebase.getReference("upload/text"); - private ChildEventListener _upload_text_child_listener; - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private StorageReference music_image = _firebase_storage.getReference("upload/image"); - private OnCompleteListener _music_image_upload_success_listener; - private OnSuccessListener _music_image_download_success_listener; - private OnSuccessListener _music_image_delete_success_listener; - private OnProgressListener _music_image_upload_progress_listener; - private OnProgressListener _music_image_download_progress_listener; - private OnFailureListener _music_image_failure_listener; - private SharedPreferences data; - private Intent intent = new Intent(); - private AlertDialog.Builder warn_dialog; - private String _reservedFilename = ""; - - { - } - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.upload); - com.google.firebase.FirebaseApp.initializeApp(this); - initialize(_savedInstanceState); - if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED - || ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) { - ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1000); - } else { - initializeLogic(); - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1000) { - initializeLogic(); - } - } - - private void initialize(Bundle _savedInstanceState) { - - linear1 = findViewById(R.id.linear1); - linear2 = findViewById(R.id.linear2); - image_back = findViewById(R.id.image_back); - textview_title = findViewById(R.id.textview_title); - linear7 = findViewById(R.id.linear7); - linear5 = findViewById(R.id.linear5); - linear4 = findViewById(R.id.linear4); - edittext_name = findViewById(R.id.edittext_name); - button_upload = findViewById(R.id.button_upload); - textview_path = findViewById(R.id.textview_path); - imageview1 = findViewById(R.id.imageview1); - textview_upload = findViewById(R.id.textview_upload); - textview_prog = findViewById(R.id.textview_prog); - progressbar1 = findViewById(R.id.progressbar1); - Auth = FirebaseAuth.getInstance(); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - warn_dialog = new AlertDialog.Builder(this); - - image_back.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (!isExitDisabled) { - finish(); - } - } - }); - - button_upload.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (21 > (FileUtil.getFileLength(path) / 1048576)) { - if (edittext_name.getText().toString().trim().length() > 0) { - if (indexName.contains(edittext_name.getText().toString().trim())) { - _customSnack("Music name already exist.", 2); - } else { - warn_dialog.setTitle("Warning"); - warn_dialog.setMessage("Before you upload this music, we just want to warn you. Any copyrighted contents will be DELETED fastly or slowly, so please upload any contents that are free of any copyright instead. If you still wants to upload any copyrighted contents, please ask the creator for permission."); - warn_dialog.setPositiveButton("I understand", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - name = edittext_name.getText().toString().trim(); - _reservedFilename = name.replace("/", " "); - upload_storage.child(FirebaseAuth.getInstance().getCurrentUser().getUid().concat("/".concat(_reservedFilename.concat(Uri.parse(path).getLastPathSegment().replace(Uri.parse(path).getLastPathSegment().substring(0, Uri.parse(path).getLastPathSegment().lastIndexOf(".")), ""))))).putFile(Uri.fromFile(new File(path))).addOnFailureListener(_upload_storage_failure_listener).addOnProgressListener(_upload_storage_upload_progress_listener).continueWithTask(new Continuation>() { - @Override - public Task then(Task task) throws Exception { - return upload_storage.child(FirebaseAuth.getInstance().getCurrentUser().getUid().concat("/".concat(_reservedFilename.concat(Uri.parse(path).getLastPathSegment().replace(Uri.parse(path).getLastPathSegment().substring(0, Uri.parse(path).getLastPathSegment().lastIndexOf(".")), ""))))).getDownloadUrl(); - } - }).addOnCompleteListener(_upload_storage_upload_success_listener); - textview_prog.setText(edittext_name.getText().toString().trim()); - linear7.setVisibility(View.GONE); - linear5.setVisibility(View.VISIBLE); - isExitDisabled = true; - } - }); - warn_dialog.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - - } - }); - warn_dialog.create().show(); - } - } else { - _customSnack("Music name can't be empty.", 2); - } - } else { - _customSnack("File size can't be bigger than 20 MB.", 2); - } - } - }); - - imageview1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - intent.setClass(getApplicationContext(), FilepickerActivity.class); - intent.putExtra("fileType", "audio/*"); - startActivity(intent); - } - }); - - _upload_storage_upload_progress_listener = new OnProgressListener() { - @Override - public void onProgress(UploadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - if (img_path.equals("")) { - progressbar1.setProgress((int) _progressValue); - } else { - progressbar1.setProgress((int) _progressValue / 2); - } - } - }; - - _upload_storage_download_progress_listener = new OnProgressListener() { - @Override - public void onProgress(FileDownloadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _upload_storage_upload_success_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final String _downloadUrl = _param1.getResult().toString(); - if (img_path.equals("")) { - upload_map = new HashMap<>(); - upload_map.put("url", _downloadUrl); - upload_map.put("name", name); - upload_map.put("view", "0"); - upload_map.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - upload_text.push().updateChildren(upload_map); - SketchwareUtil.showMessage(getApplicationContext(), "Upload Completed!"); - finish(); - } else { - tmpurl = _downloadUrl; - music_image.child(FirebaseAuth.getInstance().getCurrentUser().getUid().concat("/".concat(_reservedFilename.concat(".png")))).putFile(Uri.fromFile(new File(img_path))).addOnFailureListener(_music_image_failure_listener).addOnProgressListener(_music_image_upload_progress_listener).continueWithTask(new Continuation>() { - @Override - public Task then(Task task) throws Exception { - return music_image.child(FirebaseAuth.getInstance().getCurrentUser().getUid().concat("/".concat(_reservedFilename.concat(".png")))).getDownloadUrl(); - } - }).addOnCompleteListener(_music_image_upload_success_listener); - } - } - }; - - _upload_storage_download_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot _param1) { - final long _totalByteCount = _param1.getTotalByteCount(); - - } - }; - - _upload_storage_delete_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(Object _param1) { - - } - }; - - _upload_storage_failure_listener = new OnFailureListener() { - @Override - public void onFailure(Exception _param1) { - final String _message = _param1.getMessage(); - SketchwareUtil.showMessage(getApplicationContext(), _message); - finish(); - } - }; - - _upload_text_child_listener = new ChildEventListener() { - @Override - public void onChildAdded(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - indexName.add(_childValue.get("name").toString()); - } - - @Override - public void onChildChanged(DataSnapshot _param1, String _param2) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - - } - - @Override - public void onChildMoved(DataSnapshot _param1, String _param2) { - - } - - @Override - public void onChildRemoved(DataSnapshot _param1) { - GenericTypeIndicator> _ind = new GenericTypeIndicator>() { - }; - final String _childKey = _param1.getKey(); - final HashMap _childValue = _param1.getValue(_ind); - if (indexName.contains(_childValue.get("name").toString())) { - indexName.remove(indexName.indexOf(_childValue.get("name").toString())); - } - } - - @Override - public void onCancelled(DatabaseError _param1) { - final int _errorCode = _param1.getCode(); - final String _errorMessage = _param1.getMessage(); - - } - }; - upload_text.addChildEventListener(_upload_text_child_listener); - - _music_image_upload_progress_listener = new OnProgressListener() { - @Override - public void onProgress(UploadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - progressbar1.setProgress((int) (50 + (_progressValue / 2))); - } - }; - - _music_image_download_progress_listener = new OnProgressListener() { - @Override - public void onProgress(FileDownloadTask.TaskSnapshot _param1) { - double _progressValue = (100.0 * _param1.getBytesTransferred()) / _param1.getTotalByteCount(); - - } - }; - - _music_image_upload_success_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final String _downloadUrl = _param1.getResult().toString(); - FileUtil.deleteFile(img_path); - upload_map = new HashMap<>(); - upload_map.put("url", tmpurl); - upload_map.put("name", name); - upload_map.put("view", "0"); - upload_map.put("uid", FirebaseAuth.getInstance().getCurrentUser().getUid()); - upload_map.put("img", _downloadUrl); - upload_text.push().updateChildren(upload_map); - SketchwareUtil.showMessage(getApplicationContext(), "Upload Completed!"); - finish(); - } - }; - - _music_image_download_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(FileDownloadTask.TaskSnapshot _param1) { - final long _totalByteCount = _param1.getTotalByteCount(); - - } - }; - - _music_image_delete_success_listener = new OnSuccessListener() { - @Override - public void onSuccess(Object _param1) { - - } - }; - - _music_image_failure_listener = new OnFailureListener() { - @Override - public void onFailure(Exception _param1) { - final String _message = _param1.getMessage(); - - } - }; - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); - _loadTheme(); - linear5.setVisibility(View.GONE); - textview_title.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - edittext_name.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - button_upload.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_path.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_upload.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - textview_prog.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - } - - @Override - protected void onActivityResult(int _requestCode, int _resultCode, Intent _data) { - super.onActivityResult(_requestCode, _resultCode, _data); - - switch (_requestCode) { - - default: - break; - } - } - - @Override - public void onBackPressed() { - if (!isExitDisabled) { - finish(); - } - } - - @Override - public void onResume() { - super.onResume(); - if (!data.getString("tmpPath", "").equals("")) { - path = data.getString("tmpPath", ""); - data.edit().remove("tmpPath").commit(); - if (FileUtil.isExistFile(path)) { - if (FileUtil.isExistFile(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tmp.png"))) { - FileUtil.deleteFile(FileUtil.getPackageDataDir(getApplicationContext()).concat("/tmp.png")); - } - edittext_name.setEnabled(true); - button_upload.setEnabled(true); - edittext_name.setAlpha((float) (1)); - button_upload.setAlpha((float) (1)); - textview_path.setText(path); - edittext_name.setText(Uri.parse(path).getLastPathSegment().substring(0, Uri.parse(path).getLastPathSegment().lastIndexOf(".")).replace("_", " ")); - try { - img_path = FileUtil.getPackageDataDir(getApplicationContext()).concat("/tmp.png"); - MediaMetadataRetriever mmr = new MediaMetadataRetriever(); - mmr.setDataSource(path); - byte[] data = mmr.getEmbeddedPicture(); - Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length); - imageview1.clearColorFilter(); - { - Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(output); - final int color = 0xff424242; - final Paint paint = new Paint(); - final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); - final RectF rectF = new RectF(rect); - final float roundPx = 15; - paint.setAntiAlias(true); - canvas.drawARGB(0, 0, 0, 0); - paint.setColor(color); - canvas.drawRoundRect(rectF, roundPx, roundPx, paint); - paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); - canvas.drawBitmap(bitmap, rect, rect, paint); - imageview1.setImageBitmap(output); - } - - java.io.File file = new java.io.File(img_path); - java.io.FileOutputStream fOut = new java.io.FileOutputStream(file); - bitmap.compress(Bitmap.CompressFormat.PNG, 100, fOut); - } catch (Exception e) { - imageview1.setImageResource(R.drawable.ic_album_white); - img_path = ""; - if (data.getString("themesactive", "").equals("1")) { - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - } else { - imageview1.clearColorFilter(); - } - } - } - } - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - private void _customNav(final String _color) { - //Code From StackOverFlow.com And Converted By TeamWorks DEV - if (Build.VERSION.SDK_INT >= 21) { - Window w = this.getWindow(); - w.setNavigationBarColor(Color.parseColor(_color)); - } - } - - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _circleRipple(final String _color, final View _v) { - android.content.res.ColorStateList clrb = new android.content.res.ColorStateList(new int[][]{new int[]{}}, new int[]{Color.parseColor(_color)}); - android.graphics.drawable.RippleDrawable ripdrb = new android.graphics.drawable.RippleDrawable(clrb, null, null); - _v.setBackground(ripdrb); - } - - - private void _loadTheme() { - theme_map = new Gson().fromJson(data.getString("themesjson", ""), new TypeToken>>() { - }.getType()); - _circleRipple(theme_map.get(0).get("colorRipple").toString(), image_back); - _customNav(theme_map.get(0).get("colorBackground").toString()); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), theme_map.get(0).get("colorBackgroundCard").toString(), "#FFFFFF", 0, linear5); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), theme_map.get(0).get("colorBackgroundCard").toString(), "#FFFFFF", 0, linear7); - _shape(SketchwareUtil.getDip(getApplicationContext(), 5), SketchwareUtil.getDip(getApplicationContext(), 5), SketchwareUtil.getDip(getApplicationContext(), 5), SketchwareUtil.getDip(getApplicationContext(), 5), theme_map.get(0).get("colorButton").toString(), "#FFFFFF", 0, imageview1); - _shape(SketchwareUtil.getDip(getApplicationContext(), 5), SketchwareUtil.getDip(getApplicationContext(), 5), SketchwareUtil.getDip(getApplicationContext(), 5), SketchwareUtil.getDip(getApplicationContext(), 5), theme_map.get(0).get("colorButton").toString(), "#FFFFFF", 0, button_upload); - if (theme_map.get(0).get("shadow").toString().equals("1")) { - _shadow(linear1, 10); - _shadow(linear5, 8); - _shadow(linear7, 8); - } - if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) { - Window w = this.getWindow(); - w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); - w.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - w.setStatusBarColor(Color.parseColor(theme_map.get(0).get("colorPrimaryDark").toString())); - } - linear1.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorPrimary").toString())); - linear2.setBackgroundColor(Color.parseColor(theme_map.get(0).get("colorBackground").toString())); - edittext_name.setHintTextColor(Color.parseColor(theme_map.get(0).get("colorHint").toString())); - textview_title.setTextColor(Color.parseColor(theme_map.get(0).get("colorPrimaryText").toString())); - textview_upload.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - textview_prog.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - progressbar1.getProgressDrawable().setColorFilter(Color.parseColor(theme_map.get(0).get("colorButton").toString()), PorterDuff.Mode.SRC_IN); - textview_path.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - edittext_name.setTextColor(Color.parseColor(theme_map.get(0).get("colorBackgroundCardText").toString())); - button_upload.setTextColor(Color.parseColor(theme_map.get(0).get("colorButtonText").toString())); - imageview1.setColorFilter(Color.parseColor(theme_map.get(0).get("colorButtonText").toString()), PorterDuff.Mode.MULTIPLY); - if (theme_map.get(0).get("statusbarIcon").toString().equals("0")) { - _BlackStatusBarIcons(); - } - image_back.setColorFilter(Color.parseColor(theme_map.get(0).get("colorPrimaryImage").toString()), PorterDuff.Mode.MULTIPLY); - } - - - private void _BlackStatusBarIcons() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - } - - - private void _customSnack(final String _txt, final double _icon) { - // Create the Snackbar - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - // Get the Snackbar's layout view - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - // Inflate our custom view - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - // Configure the view - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - // Add the view to the Snackbar's layout - layout.addView(snackview, 0); - // Show the Snackbar - snackbar.show(); - } - - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public ArrayList getCheckedItemPositionsToArray(ListView _list) { - ArrayList _result = new ArrayList(); - SparseBooleanArray _arr = _list.getCheckedItemPositions(); - for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) { - if (_arr.valueAt(_iIdx)) - _result.add((double) _arr.keyAt(_iIdx)); - } - return _result; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - -} diff --git a/app/src/main/java/tw/music/streamer/WizardActivity.java b/app/src/main/java/tw/music/streamer/WizardActivity.java deleted file mode 100644 index 4330db6..0000000 --- a/app/src/main/java/tw/music/streamer/WizardActivity.java +++ /dev/null @@ -1,891 +0,0 @@ -package tw.music.streamer; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.ProgressDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.SharedPreferences; -import android.content.pm.PackageManager; -import android.graphics.Color; -import android.graphics.PorterDuff; -import android.graphics.Typeface; -import android.net.Uri; -import android.os.Build; -import android.os.Bundle; -import android.text.Editable; -import android.text.InputType; -import android.text.TextWatcher; -import android.util.SparseBooleanArray; -import android.util.TypedValue; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.Window; -import android.widget.Button; -import android.widget.CheckBox; -import android.widget.CompoundButton; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.ListView; -import android.widget.ScrollView; -import android.widget.TextView; -import android.widget.Toast; - -import android.Manifest; -import android.content.pm.PackageManager; -import android.provider.Settings; - -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; -import androidx.core.app.NotificationManagerCompat; -import androidx.core.content.ContextCompat; - -import com.google.android.gms.tasks.OnCompleteListener; -import com.google.android.gms.tasks.Task; -import com.google.android.material.floatingactionbutton.FloatingActionButton; -import com.google.firebase.auth.AuthResult; -import com.google.firebase.auth.FirebaseAuth; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Random; -import java.util.Timer; -import java.util.TimerTask; - -public class WizardActivity extends AppCompatActivity { - - private Timer _timer = new Timer(); - - private FloatingActionButton _fab; - private double currentSetup = 0; - private boolean isLogin = false; - - private ArrayList listSetup = new ArrayList<>(); - - private LinearLayout linear2; - private LinearLayout linear6; - private LinearLayout linear10; - private LinearLayout linear17; - private LinearLayout linear3; - private TextView textview2; - private TextView textview3; - private LinearLayout linear7; - private LinearLayout linear4; - private LinearLayout linear16; - private LinearLayout linear5; - private TextView textview4; - private TextView textview5; - private Button button2; - private LinearLayout linear11; - private LinearLayout linear13; - private LinearLayout linear12; - private ImageView imageview3; - private TextView textview6; - private TextView textview7; - private LinearLayout linear14; - private TextView textview8; - private EditText edittext1; - private TextView textview9; - private EditText edittext2; - private TextView textview10; - private Button button1; - private LinearLayout linear15; - private TextView textview11; - private TextView textview12; - private ScrollView vscroll1; - private CheckBox checkbox1; - private LinearLayout linear18; - private TextView textview13; - private Button button3; - - private FirebaseAuth Auth; - private OnCompleteListener _Auth_create_user_listener; - private OnCompleteListener _Auth_sign_in_listener; - private OnCompleteListener _Auth_reset_password_listener; - private TimerTask delay; - private SharedPreferences data; - private Intent intent = new Intent(); - private AlertDialog.Builder dialog; - private ProgressDialog coreprog; - - @Override - protected void onCreate(Bundle _savedInstanceState) { - super.onCreate(_savedInstanceState); - setContentView(R.layout.wizard); - initialize(_savedInstanceState); - initializeLogic(); - } - - private void initialize(Bundle _savedInstanceState) { - - _fab = findViewById(R.id._fab); - - linear2 = findViewById(R.id.linear2); - linear6 = findViewById(R.id.linear6); - linear10 = findViewById(R.id.linear10); - linear17 = findViewById(R.id.linear17); - linear3 = findViewById(R.id.linear3); - textview2 = findViewById(R.id.textview2); - textview3 = findViewById(R.id.textview3); - linear7 = findViewById(R.id.linear7); - linear4 = findViewById(R.id.linear4); - linear16 = findViewById(R.id.linear16); - linear5 = findViewById(R.id.linear5); - textview4 = findViewById(R.id.textview4); - textview5 = findViewById(R.id.textview5); - button2 = findViewById(R.id.button2); - linear11 = findViewById(R.id.linear11); - linear13 = findViewById(R.id.linear13); - linear12 = findViewById(R.id.linear12); - imageview3 = findViewById(R.id.imageview3); - textview6 = findViewById(R.id.textview6); - textview7 = findViewById(R.id.textview7); - linear14 = findViewById(R.id.linear14); - textview8 = findViewById(R.id.textview8); - edittext1 = findViewById(R.id.edittext1); - textview9 = findViewById(R.id.textview9); - edittext2 = findViewById(R.id.edittext2); - textview10 = findViewById(R.id.textview10); - button1 = findViewById(R.id.button1); - linear15 = findViewById(R.id.linear15); - textview11 = findViewById(R.id.textview11); - textview12 = findViewById(R.id.textview12); - vscroll1 = findViewById(R.id.vscroll1); - checkbox1 = findViewById(R.id.checkbox1); - linear18 = findViewById(R.id.linear18); - textview13 = findViewById(R.id.textview13); - button3 = findViewById(R.id.button3); - Auth = FirebaseAuth.getInstance(); - data = getSharedPreferences("teamdata", Activity.MODE_PRIVATE); - dialog = new AlertDialog.Builder(this); - - button2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _grantPermission(); - } - }); - - edittext1.addTextChangedListener(new TextWatcher() { - @Override - public void onTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - final String _charSeq = _param1.toString(); - if (android.util.Patterns.EMAIL_ADDRESS.matcher(edittext1.getText().toString()).matches()) - edittext1.setError(null); - else - edittext1.setError("Invalid email!"); - } - - @Override - public void beforeTextChanged(CharSequence _param1, int _param2, int _param3, int _param4) { - - } - - @Override - public void afterTextChanged(Editable _param1) { - - } - }); - - textview10.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - - LinearLayout mylayout = new LinearLayout(WizardActivity.this); - - LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); - - mylayout.setLayoutParams(params); - mylayout.setOrientation(LinearLayout.VERTICAL); - - final EditText myedittext = new EditText(WizardActivity.this); - myedittext.setLayoutParams(new LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, android.widget.LinearLayout.LayoutParams.WRAP_CONTENT)); - myedittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); - myedittext.setText(edittext1.getText().toString()); - - mylayout.addView(myedittext); - dialog.setView(mylayout); - myedittext.setHint("Enter your Email"); - dialog.setCancelable(false); - dialog.setTitle("Reset Password"); - dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - _abandonFocus(); - if (myedittext.getText().toString().trim().length() > 0) { - Auth.sendPasswordResetEmail(myedittext.getText().toString()).addOnCompleteListener(_Auth_reset_password_listener); - _customSnack("Check your e-mail to change password.", 1); - } else { - _customSnack("Fill those blank!", 2); - } - } - }); - dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - _abandonFocus(); - } - }); - dialog.create().show(); - } - }); - - button1.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (edittext1.getText().toString().trim().equals("")) { - _customSnack("Fill those blanks!", 2); - edittext1.requestFocus(); - } else { - if (edittext2.getText().toString().equals("")) { - _customSnack("Fill those blanks!", 2); - edittext2.requestFocus(); - } else { - _CoreProgressLoading(true); - if (isLogin) { - Auth.signInWithEmailAndPassword(edittext1.getText().toString().trim(), edittext2.getText().toString()).addOnCompleteListener(WizardActivity.this, _Auth_sign_in_listener); - } else { - Auth.createUserWithEmailAndPassword(edittext1.getText().toString().trim(), edittext2.getText().toString()).addOnCompleteListener(WizardActivity.this, _Auth_create_user_listener); - } - } - } - } - }); - - textview12.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - if (isLogin) { - isLogin = false; - button1.setText("Sign Up"); - textview12.setText("Sign In"); - textview10.setVisibility(View.GONE); - textview11.setText("Old user?"); - } else { - isLogin = true; - button1.setText("Login"); - textview12.setText("Sign Up"); - textview10.setVisibility(View.VISIBLE); - textview11.setText("New user?"); - } - } - }); - - checkbox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton _param1, boolean _param2) { - final boolean _isChecked = _param2; - if (_isChecked) { - button3.setEnabled(true); - button3.setAlpha((float) (1.0d)); - } else { - button3.setEnabled(false); - button3.setAlpha((float) (0.5d)); - } - } - }); - - button3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _nextSetup(); - } - }); - - _fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View _view) { - _nextSetup(); - } - }); - - _Auth_create_user_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - _CoreProgressLoading(false); - if (_success) { - Auth.getCurrentUser().sendEmailVerification().addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(@androidx.annotation.NonNull Task task) { - - if (task.isSuccessful()) { - _customSnack("Check your email to verify your account.", 1); - } else { - _customSnack("Account verification failed to send!", 2); - } - - } - }); - FirebaseAuth.getInstance().signOut(); - } else { - _customSnack(_errorMessage, 2); - FirebaseAuth.getInstance().signOut(); - } - } - }; - - _Auth_sign_in_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - final String _errorMessage = _param1.getException() != null ? _param1.getException().getMessage() : ""; - _CoreProgressLoading(false); - if (_success) { - if (Auth.getCurrentUser().isEmailVerified()) { - _nextSetup(); - } else { - dialog.setCancelable(false); - dialog.setTitle("Email is not verified"); - dialog.setMessage("Would you to re-verify? "); - dialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - Auth.getCurrentUser().sendEmailVerification().addOnCompleteListener(new OnCompleteListener() { - @Override - public void onComplete(@androidx.annotation.NonNull Task task) { - - if (task.isSuccessful()) { - _customSnack("Open your email to verify your account.", 1); - } else { - _customSnack("Account verification failed to send!", 2); - } - - } - }); - FirebaseAuth.getInstance().signOut(); - } - }); - dialog.setNegativeButton("No", new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface _dialog, int _which) { - _resetDialog(); - FirebaseAuth.getInstance().signOut(); - } - }); - dialog.create().show(); - } - } else { - _customSnack(_errorMessage, 2); - FirebaseAuth.getInstance().signOut(); - } - } - }; - - _Auth_reset_password_listener = new OnCompleteListener() { - @Override - public void onComplete(Task _param1) { - final boolean _success = _param1.isSuccessful(); - - } - }; - } - - private void initializeLogic() { - button1.setAllCaps(false); - button2.setAllCaps(false); - _fab.hide(); - edittext1.getBackground().setColorFilter(Color.parseColor("#2196F3"), PorterDuff.Mode.SRC_ATOP); - edittext2.getBackground().setColorFilter(Color.parseColor("#2196F3"), PorterDuff.Mode.SRC_ATOP); - edittext1.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); - _customNav("#FFFFFF"); - _BlackStatusBarIcons(); - _setFont(); - linear2.setVisibility(View.GONE); - linear6.setVisibility(View.GONE); - linear10.setVisibility(View.GONE); - textview10.setVisibility(View.GONE); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), "#2196F3", "#FFFFFF", 0, button1); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), "#3F51B5", "#FFFFFF", 0, button2); - _shape(SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), SketchwareUtil.getDip(getApplicationContext(), (int) (2.5d)), "#2196F3", "#FFFFFF", 0, button3); - _shadow(linear7, 10); - _shadow(linear11, 10); - button3.setEnabled(false); - button3.setAlpha(0.5f); - textview13.setText("MIT License\nLast updated: 2019-10-05\n\nCopyright © 2017 ZryteZene All rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification,\nare permitted provided that the following conditions are met:\n* Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n* Redistributions in binary form must reproduce the above copyright notice, this\n list of conditions and the following disclaimer in the documentation and/or\n other materials provided with the distribution.\n* Neither the name of ZryteZene nor the names of its contributors may be used to\n endorse or promote products derived from this software without specific prior\n written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\nANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\nANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n\nTERMS AND CONDITIONS\nLast updated: 2020-04-05\n\n1. Introduction\n\nWelcome to Zrytezene (“Company”, “we”, “our”, “us”)!\n\nThese Terms of Service (“Terms”, “Terms of Service”) govern your use of our website located at https://zrytezene.web.app (together or individually “Service”) operated by ZryteZene.\n\nOur Privacy Policy also governs your use of our Service and explains how we collect, safeguard and disclose information that results from your use of our web pages.\n\nYour agreement with us includes these Terms and our Privacy Policy (“Agreements”). You acknowledge that you have read and understood Agreements, and agree to be bound of them.\n\nIf you do not agree with (or cannot comply with) Agreements, then you may not use the Service, but please let us know by emailing at zrytezene@gmail.com so we can try to find a solution. These Terms apply to all visitors, users and others who wish to access or use Service.\n\n2. Communications\n\nBy using our Service, you agree to subscribe to newsletters, marketing or promotional materials and other information we may send. However, you may opt out of receiving any, or all, of these communications from us by following the unsubscribe link or by emailing at zrytezene@gmail.com.\n\n3. Contests, Sweepstakes and Promotions\n\nAny contests, sweepstakes or other promotions (collectively, “Promotions”) made available through Service may be governed by rules that are separate from these Terms of Service. If you participate in any Promotions, please review the applicable rules as well as our Privacy Policy. If the rules for a Promotion conflict with these Terms of Service, Promotion rules will apply.\n\n4. Content\n\nOur Service allows you to post, link, store, share and otherwise make available certain information, text, graphics, videos, or other material (“Content”). You are responsible for Content that you post on or through Service, including its legality, reliability, and appropriateness.\n\nBy posting Content on or through Service, You represent and warrant that: (i) Content is yours (you own it) and/or you have the right to use it and the right to grant us the rights and license as provided in these Terms, and (ii) that the posting of your Content on or through Service does not violate the privacy rights, publicity rights, copyrights, contract rights or any other rights of any person or entity. We reserve the right to terminate the account of anyone found to be infringing on a copyright.\n\nYou retain any and all of your rights to any Content you submit, post or display on or through Service and you are responsible for protecting those rights. We take no responsibility and assume no liability for Content you or any third party posts on or through Service. However, by posting Content using Service you grant us the right and license to use, modify, publicly perform, publicly display, reproduce, and distribute such Content on and through Service. You agree that this license includes the right for us to make your Content available to other users of Service, who may also use your Content subject to these Terms.\n\nZryteZene has the right but not the obligation to monitor and edit all Content provided by users.\n\nIn addition, Content found on or through this Service are the property of ZryteZene or used with permission. You may not distribute, modify, transmit, reuse, download, repost, copy, or use said Content, whether in whole or in part, for commercial purposes or for personal gain, without express advance written permission from us.\n\n5. Prohibited Uses\n\nYou may use Service only for lawful purposes and in accordance with Terms. You agree not to use Service:\n\n0.1. In any way that violates any applicable national or international law or regulation.\n\n0.2. For the purpose of exploiting, harming, or attempting to exploit or harm minors in any way by exposing them to inappropriate content or otherwise.\n\n0.3. To transmit, or procure the sending of, any advertising or promotional material, including any “junk mail”, “chain letter,” “spam,” or any other similar solicitation.\n\n0.4. To impersonate or attempt to impersonate Company, a Company employee, another user, or any other person or entity.\n\n0.5. In any way that infringes upon the rights of others, or in any way is illegal, threatening, fraudulent, or harmful, or in connection with any unlawful, illegal, fraudulent, or harmful purpose or activity.\n\n0.6. To engage in any other conduct that restricts or inhibits anyone’s use or enjoyment of Service, or which, as determined by us, may harm or offend Company or users of Service or expose them to liability.\n\nAdditionally, you agree not to:\n\n0.1. Use Service in any manner that could disable, overburden, damage, or impair Service or interfere with any other party’s use of Service, including their ability to engage in real time activities through Service.\n\n0.2. Use any robot, spider, or other automatic device, process, or means to access Service for any purpose, including monitoring or copying any of the material on Service.\n\n0.3. Use any manual process to monitor or copy any of the material on Service or for any other unauthorized purpose without our prior written consent.\n\n0.4. Use any device, software, or routine that interferes with the proper working of Service.\n\n0.5. Introduce any viruses, trojan horses, worms, logic bombs, or other material which is malicious or technologically harmful.\n\n0.6. Attempt to gain unauthorized access to, interfere with, damage, or disrupt any parts of Service, the server on which Service is stored, or any server, computer, or database connected to Service.\n\n0.7. Attack Service via a denial-of-service attack or a distributed denial-of-service attack.\n\n0.8. Take any action that may damage or falsify Company rating.\n\n0.9. Otherwise attempt to interfere with the proper working of Service.\n\n6. Analytics\n\nWe may use third-party Service Providers to monitor and analyze the use of our Service.\n\n7. No Use By Minors\n\nService is intended only for access and use by individuals at least eighteen (18) years old. By accessing or using Service, you warrant and represent that you are at least eighteen (18) years of age and with the full authority, right, and capacity to enter into this agreement and abide by all of the terms and conditions of Terms. If you are not at least eighteen (18) years old, you are prohibited from both the access and usage of Service.\n\n8. Accounts\n\nWhen you create an account with us, you guarantee that you are above the age of 18, and that the information you provide us is accurate, complete, and current at all times. Inaccurate, incomplete, or obsolete information may result in the immediate termination of your account on Service.\n\nYou are responsible for maintaining the confidentiality of your account and password, including but not limited to the restriction of access to your computer and/or account. You agree to accept responsibility for any and all activities or actions that occur under your account and/or password, whether your password is with our Service or a third-party service. You must notify us immediately upon becoming aware of any breach of security or unauthorized use of your account.\n\nYou may not use as a username the name of another person or entity or that is not lawfully available for use, a name or trademark that is subject to any rights of another person or entity other than you, without appropriate authorization. You may not use as a username any name that is offensive, vulgar or obscene.\n\nWe reserve the right to refuse service, terminate accounts, remove or edit content, or cancel orders in our sole discretion.\n\n9. Intellectual Property\n\nService and its original content (excluding Content provided by users), features and functionality are and will remain the exclusive property of ZryteZene and its licensors. Service is protected by copyright, trademark, and other laws of and foreign countries. Our trademarks may not be used in connection with any product or service without the prior written consent of ZryteZene.\n\n10. Copyright Policy\n\nWe respect the intellectual property rights of others. It is our policy to respond to any claim that Content posted on Service infringes on the copyright or other intellectual property rights (“Infringement”) of any person or entity.\n\nIf you are a copyright owner, or authorized on behalf of one, and you believe that the copyrighted work has been copied in a way that constitutes copyright infringement, please submit your claim via email to zrytezene@gmail.com, with the subject line: “Copyright Infringement” and include in your claim a detailed description of the alleged Infringement as detailed below, under “DMCA Notice and Procedure for Copyright Infringement Claims”\n\nYou may be held accountable for damages (including costs and attorneys’ fees) for misrepresentation or bad-faith claims on the infringement of any Content found on and/or through Service on your copyright.\n\n11. DMCA Notice and Procedure for Copyright Infringement Claims\n\nYou may submit a notification pursuant to the Digital Millennium Copyright Act (DMCA) by providing our Copyright Agent with the following information in writing (see 17 U.S.C 512(c)(3) for further detail):\n\n0.1. an electronic or physical signature of the person authorized to act on behalf of the owner of the copyright’s interest;\n\n0.2. a description of the copyrighted work that you claim has been infringed, including the URL (i.e., web page address) of the location where the copyrighted work exists or a copy of the copyrighted work;\n\n0.3. identification of the URL or other specific location on Service where the material that you claim is infringing is located;\n\n0.4. your address, telephone number, and email address;\n\n0.5. a statement by you that you have a good faith belief that the disputed use is not authorized by the copyright owner, its agent, or the law;\n\n0.6. a statement by you, made under penalty of perjury, that the above information in your notice is accurate and that you are the copyright owner or authorized to act on the copyright owner’s behalf.\n\nYou can contact our Copyright Agent via email at zrytezene@gmail.com.\n\n12. Error Reporting and Feedback\n\nYou may provide us either directly at zrytezene@gmail.com or via third party sites and tools with information and feedback concerning errors, suggestions for improvements, ideas, problems, complaints, and other matters related to our Service (“Feedback”). You acknowledge and agree that: (i) you shall not retain, acquire or assert any intellectual property right or other right, title or interest in or to the Feedback; (ii) Company may have development ideas similar to the Feedback; (iii) Feedback does not contain confidential information or proprietary information from you or any third party; and (iv) Company is not under any obligation of confidentiality with respect to the Feedback. In the event the transfer of the ownership to the Feedback is not possible due to applicable mandatory laws, you grant Company and its affiliates an exclusive, transferable, irrevocable, free-of-charge, sub-licensable, unlimited and perpetual right to use (including copy, modify, create derivative works, publish, distribute and commercialize) Feedback in any manner and for any purpose.\n\n13. Links To Other Web Sites\n\nOur Service may contain links to third party web sites or services that are not owned or controlled by ZryteZene.\n\nZryteZene has no control over, and assumes no responsibility for the content, privacy policies, or practices of any third party web sites or services. We do not warrant the offerings of any of these entities/individuals or their websites.\n\nFor example, the outlined Terms of Service have been created using PolicyMaker.io, a free web application for generating high-quality legal documents. PolicyMaker’s free Terms and Conditions generator is an easy-to-use free tool for creating an excellent Terms of Service template for a website, blog, online store or app.\n\nYOU ACKNOWLEDGE AND AGREE THAT COMPANY SHALL NOT BE RESPONSIBLE OR LIABLE, DIRECTLY OR INDIRECTLY, FOR ANY DAMAGE OR LOSS CAUSED OR ALLEGED TO BE CAUSED BY OR IN CONNECTION WITH USE OF OR RELIANCE ON ANY SUCH CONTENT, GOODS OR SERVICES AVAILABLE ON OR THROUGH ANY SUCH THIRD PARTY WEB SITES OR SERVICES.\n\nWE STRONGLY ADVISE YOU TO READ THE TERMS OF SERVICE AND PRIVACY POLICIES OF ANY THIRD PARTY WEB SITES OR SERVICES THAT YOU VISIT.\n\n14. Disclaimer Of Warranty\n\nTHESE SERVICES ARE PROVIDED BY COMPANY ON AN “AS IS” AND “AS AVAILABLE” BASIS. COMPANY MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, AS TO THE OPERATION OF THEIR SERVICES, OR THE INFORMATION, CONTENT OR MATERIALS INCLUDED THEREIN. YOU EXPRESSLY AGREE THAT YOUR USE OF THESE SERVICES, THEIR CONTENT, AND ANY SERVICES OR ITEMS OBTAINED FROM US IS AT YOUR SOLE RISK.\n\nNEITHER COMPANY NOR ANY PERSON ASSOCIATED WITH COMPANY MAKES ANY WARRANTY OR REPRESENTATION WITH RESPECT TO THE COMPLETENESS, SECURITY, RELIABILITY, QUALITY, ACCURACY, OR AVAILABILITY OF THE SERVICES. WITHOUT LIMITING THE FOREGOING, NEITHER COMPANY NOR ANYONE ASSOCIATED WITH COMPANY REPRESENTS OR WARRANTS THAT THE SERVICES, THEIR CONTENT, OR ANY SERVICES OR ITEMS OBTAINED THROUGH THE SERVICES WILL BE ACCURATE, RELIABLE, ERROR-FREE, OR UNINTERRUPTED, THAT DEFECTS WILL BE CORRECTED, THAT THE SERVICES OR THE SERVER THAT MAKES IT AVAILABLE ARE FREE OF VIRUSES OR OTHER HARMFUL COMPONENTS OR THAT THE SERVICES OR ANY SERVICES OR ITEMS OBTAINED THROUGH THE SERVICES WILL OTHERWISE MEET YOUR NEEDS OR EXPECTATIONS.\n\nCOMPANY HEREBY DISCLAIMS ALL WARRANTIES OF ANY KIND, WHETHER EXPRESS OR IMPLIED, STATUTORY, OR OTHERWISE, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, NON-INFRINGEMENT, AND FITNESS FOR PARTICULAR PURPOSE.\n\nTHE FOREGOING DOES NOT AFFECT ANY WARRANTIES WHICH CANNOT BE EXCLUDED OR LIMITED UNDER APPLICABLE LAW.\n\n15. Limitation Of Liability\n\nEXCEPT AS PROHIBITED BY LAW, YOU WILL HOLD US AND OUR OFFICERS, DIRECTORS, EMPLOYEES, AND AGENTS HARMLESS FOR ANY INDIRECT, PUNITIVE, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGE, HOWEVER IT ARISES (INCLUDING ATTORNEYS’ FEES AND ALL RELATED COSTS AND EXPENSES OF LITIGATION AND ARBITRATION, OR AT TRIAL OR ON APPEAL, IF ANY, WHETHER OR NOT LITIGATION OR ARBITRATION IS INSTITUTED), WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE, OR OTHER TORTIOUS ACTION, OR ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT, INCLUDING WITHOUT LIMITATION ANY CLAIM FOR PERSONAL INJURY OR PROPERTY DAMAGE, ARISING FROM THIS AGREEMENT AND ANY VIOLATION BY YOU OF ANY FEDERAL, STATE, OR LOCAL LAWS, STATUTES, RULES, OR REGULATIONS, EVEN IF COMPANY HAS BEEN PREVIOUSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EXCEPT AS PROHIBITED BY LAW, IF THERE IS LIABILITY FOUND ON THE PART OF COMPANY, IT WILL BE LIMITED TO THE AMOUNT PAID FOR THE PRODUCTS AND/OR SERVICES, AND UNDER NO CIRCUMSTANCES WILL THERE BE CONSEQUENTIAL OR PUNITIVE DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF PUNITIVE, INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE PRIOR LIMITATION OR EXCLUSION MAY NOT APPLY TO YOU.\n\n16. Termination\n\nWe may terminate or suspend your account and bar access to Service immediately, without prior notice or liability, under our sole discretion, for any reason whatsoever and without limitation, including but not limited to a breach of Terms.\n\nIf you wish to terminate your account, you may simply discontinue using Service.\n\nAll provisions of Terms which by their nature should survive termination shall survive termination, including, without limitation, ownership provisions, warranty disclaimers, indemnity and limitations of liability.\n\n17. Governing Law\n\nThese Terms shall be governed and construed in accordance with the laws of Indonesia, which governing law applies to agreement without regard to its conflict of law provisions.\n\nOur failure to enforce any right or provision of these Terms will not be considered a waiver of those rights. If any provision of these Terms is held to be invalid or unenforceable by a court, the remaining provisions of these Terms will remain in effect. These Terms constitute the entire agreement between us regarding our Service and supersede and replace any prior agreements we might have had between us regarding Service.\n\n18. Changes To Service\n\nWe reserve the right to withdraw or amend our Service, and any service or material we provide via Service, in our sole discretion without notice. We will not be liable if for any reason all or any part of Service is unavailable at any time or for any period. From time to time, we may restrict access to some parts of Service, or the entire Service, to users, including registered users.\n\n19. Amendments To Terms\n\nWe may amend Terms at any time by posting the amended terms on this site. It is your responsibility to review these Terms periodically.\n\nYour continued use of the Platform following the posting of revised Terms means that you accept and agree to the changes. You are expected to check this page frequently so you are aware of any changes, as they are binding on you.\n\nBy continuing to access or use our Service after any revisions become effective, you agree to be bound by the revised terms. If you do not agree to the new terms, you are no longer authorized to use Service.\n\n20. Waiver And Severability\n\nNo waiver by Company of any term or condition set forth in Terms shall be deemed a further or continuing waiver of such term or condition or a waiver of any other term or condition, and any failure of Company to assert a right or provision under Terms shall not constitute a waiver of such right or provision.\n\nIf any provision of Terms is held by a court or other tribunal of competent jurisdiction to be invalid, illegal or unenforceable for any reason, such provision shall be eliminated or limited to the minimum extent such that the remaining provisions of Terms will continue in full force and effect.\n\n21. Acknowledgement\n\nBY USING SERVICE OR OTHER SERVICES PROVIDED BY US, YOU ACKNOWLEDGE THAT YOU HAVE READ THESE TERMS OF SERVICE AND AGREE TO BE BOUND BY THEM.\n\n22. Contact Us\n\nPlease send your feedback, comments, requests for technical support by email: zrytezene@gmail.com.\n\n\nPRIVACY POLICY\nEffective date: 2020-04-05\n\n1. Introduction\n\nWelcome to Zrytezene.\n\nZryteZene (“us”, “we”, or “our”) operates https://zrytezene.web.app (hereinafter referred to as “Service”).\n\nOur Privacy Policy governs your visit to https://zrytezene.web.app, and explains how we collect, safeguard and disclose information that results from your use of our Service.\n\nWe use your data to provide and improve Service. By using Service, you agree to the collection and use of information in accordance with this policy. Unless otherwise defined in this Privacy Policy, the terms used in this Privacy Policy have the same meanings as in our Terms and Conditions.\n\nOur Terms and Conditions (“Terms”) govern all use of our Service and together with the Privacy Policy constitutes your agreement with us (“agreement”).\n\n2. Definitions\n\nSERVICE means the https://zrytezene.web.app website operated by ZryteZene.\n\nPERSONAL DATA means data about a living individual who can be identified from those data (or from those and other information either in our possession or likely to come into our possession).\n\nUSAGE DATA is data collected automatically either generated by the use of Service or from Service infrastructure itself (for example, the duration of a page visit).\n\nCOOKIES are small files stored on your device (computer or mobile device).\n\nDATA CONTROLLER means a natural or legal person who (either alone or jointly or in common with other persons) determines the purposes for which and the manner in which any personal data are, or are to be, processed. For the purpose of this Privacy Policy, we are a Data Controller of your data.\n\nDATA PROCESSORS (OR SERVICE PROVIDERS) means any natural or legal person who processes the data on behalf of the Data Controller. We may use the services of various Service Providers in order to process your data more effectively.\n\nDATA SUBJECT is any living individual who is the subject of Personal Data.\n\nTHE USER is the individual using our Service. The User corresponds to the Data Subject, who is the subject of Personal Data.\n\n3. Information Collection and Use\n\nWe collect several different types of information for various purposes to provide and improve our Service to you.\n\n4. Types of Data Collected\n\nPersonal Data\n\nWhile using our Service, we may ask you to provide us with certain personally identifiable information that can be used to contact or identify you (“Personal Data”). Personally identifiable information may include, but is not limited to:\n\n0.1. Email address\n\n0.2. First name and last name\n\n0.3. Phone number\n\n0.4. Address, Country, State, Province, ZIP/Postal code, City\n\n0.5. Cookies and Usage Data\n\nWe may use your Personal Data to contact you with newsletters, marketing or promotional materials and other information that may be of interest to you. You may opt out of receiving any, or all, of these communications from us by following the unsubscribe link.\n\nUsage Data\n\nWe may also collect information that your browser sends whenever you visit our Service or when you access Service by or through any device (“Usage Data”).\n\nThis Usage Data may include information such as your computer’s Internet Protocol address (e.g. IP address), browser type, browser version, the pages of our Service that you visit, the time and date of your visit, the time spent on those pages, unique device identifiers and other diagnostic data.\n\nWhen you access Service with a device, this Usage Data may include information such as the type of device you use, your device unique ID, the IP address of your device, your device operating system, the type of Internet browser you use, unique device identifiers and other diagnostic data.\n\nTracking Cookies Data\n\nWe use cookies and similar tracking technologies to track the activity on our Service and we hold certain information.\n\nCookies are files with a small amount of data which may include an anonymous unique identifier. Cookies are sent to your browser from a website and stored on your device. Other tracking technologies are also used such as beacons, tags and scripts to collect and track information and to improve and analyze our Service.\n\nYou can instruct your browser to refuse all cookies or to indicate when a cookie is being sent. However, if you do not accept cookies, you may not be able to use some portions of our Service.\n\nExamples of Cookies we use:\n\n0.1. Session Cookies: We use Session Cookies to operate our Service.\n\n0.2. Preference Cookies: We use Preference Cookies to remember your preferences and various settings.\n\n0.3. Security Cookies: We use Security Cookies for security purposes.\n\n0.4. Advertising Cookies: Advertising Cookies are used to serve you with advertisements that may be relevant to you and your interests.\n\nOther Data\n\nWhile using our Service, we may also collect the following information: sex, age, date of birth, place of birth, passport details, citizenship, registration at place of residence and actual address, telephone number (work, mobile), details of documents on education, qualification, professional training, employment agreements, non-disclosure agreements, information on bonuses and compensation, information on marital status, family members, social security (or other taxpayer identification) number, office location and other data.\n\n5. Use of Data\n\nZryteZene uses the collected data for various purposes:\n\n0.1. to provide and maintain our Service;\n\n0.2. to notify you about changes to our Service;\n\n0.3. to allow you to participate in interactive features of our Service when you choose to do so;\n\n0.4. to provide customer support;\n\n0.5. to gather analysis or valuable information so that we can improve our Service;\n\n0.6. to monitor the usage of our Service;\n\n0.7. to detect, prevent and address technical issues;\n\n0.8. to fulfil any other purpose for which you provide it;\n\n0.9. to carry out our obligations and enforce our rights arising from any contracts entered into between you and us, including for billing and collection;\n\n0.10. to provide you with notices about your account and/or subscription, including expiration and renewal notices, email-instructions, etc.;\n\n0.11. to provide you with news, special offers and general information about other goods, services and events which we offer that are similar to those that you have already purchased or enquired about unless you have opted not to receive such information;\n\n0.12. in any other way we may describe when you provide the information;\n\n0.13. for any other purpose with your consent.\n\n6. Retention of Data\n\nWe will retain your Personal Data only for as long as is necessary for the purposes set out in this Privacy Policy. We will retain and use your Personal Data to the extent necessary to comply with our legal obligations (for example, if we are required to retain your data to comply with applicable laws), resolve disputes, and enforce our legal agreements and policies.\n\nWe will also retain Usage Data for internal analysis purposes. Usage Data is generally retained for a shorter period, except when this data is used to strengthen the security or to improve the functionality of our Service, or we are legally obligated to retain this data for longer time periods.\n\n7. Transfer of Data\n\nYour information, including Personal Data, may be transferred to – and maintained on – computers located outside of your state, province, country or other governmental jurisdiction where the data protection laws may differ from those of your jurisdiction.\n\nIf you are located outside Indonesia and choose to provide information to us, please note that we transfer the data, including Personal Data, to Indonesia and process it there.\n\nYour consent to this Privacy Policy followed by your submission of such information represents your agreement to that transfer.\n\nZryteZene will take all the steps reasonably necessary to ensure that your data is treated securely and in accordance with this Privacy Policy and no transfer of your Personal Data will take place to an organisation or a country unless there are adequate controls in place including the security of your data and other personal information.\n\n8. Disclosure of Data\n\nWe may disclose personal information that we collect, or you provide:\n\n0.1. Disclosure for Law Enforcement.\n\nUnder certain circumstances, we may be required to disclose your Personal Data if required to do so by law or in response to valid requests by public authorities.\n\n0.2. Business Transaction.\n\nIf we or our subsidiaries are involved in a merger, acquisition or asset sale, your Personal Data may be transferred.\n\n0.3. Other cases. We may disclose your information also:\n\n0.3.1. to our subsidiaries and affiliates;\n\n0.3.2. to contractors, service providers, and other third parties we use to support our business;\n\n0.3.3. to fulfill the purpose for which you provide it;\n\n0.3.4. for the purpose of including your company’s logo on our website;\n\n0.3.5. for any other purpose disclosed by us when you provide the information;\n\n0.3.6. with your consent in any other cases;\n\n0.3.7. if we believe disclosure is necessary or appropriate to protect the rights, property, or safety of the Company, our customers, or others.\n\n9. Security of Data\n\nThe security of your data is important to us but remember that no method of transmission over the Internet or method of electronic storage is 100% secure. While we strive to use commercially acceptable means to protect your Personal Data, we cannot guarantee its absolute security.\n\n10. Service Providers\n\nWe may employ third party companies and individuals to facilitate our Service (“Service Providers”), provide Service on our behalf, perform Service-related services or assist us in analysing how our Service is used.\n\nThese third parties have access to your Personal Data only to perform these tasks on our behalf and are obligated not to disclose or use it for any other purpose.\n\n11. Analytics\n\nWe may use third-party Service Providers to monitor and analyze the use of our Service.\n\n12. CI/CD tools\n\nWe may use third-party Service Providers to automate the development process of our Service.\n\n13. Behavioral Remarketing\n\nWe may use remarketing services to advertise on third party websites to you after you visited our Service. We and our third-party vendors use cookies to inform, optimise and serve ads based on your past visits to our Service.\n\n14. Links to Other Sites\n\nOur Service may contain links to other sites that are not operated by us. If you click a third party link, you will be directed to that third party’s site. We strongly advise you to review the Privacy Policy of every site you visit.\n\nWe have no control over and assume no responsibility for the content, privacy policies or practices of any third party sites or services.\n\nFor example, the outlined Privacy Policy has been created using PolicyMaker.io, a free web application for generating high-quality legal documents. PolicyMaker’s online free privacy policy generator is an easy-to-use tool for creating privacy policy template for a website, blog, online store or app.\n\n15. Children’s Privacy\n\nOur Services are not intended for use by children under the age of 18 (“Child” or “Children”).\n\nWe do not knowingly collect personally identifiable information from Children under 18. If you become aware that a Child has provided us with Personal Data, please contact us. If we become aware that we have collected Personal Data from Children without verification of parental consent, we take steps to remove that information from our servers.\n\n16. Changes to This Privacy Policy\n\nWe may update our Privacy Policy from time to time. We will notify you of any changes by posting the new Privacy Policy on this page.\n\nWe will let you know via email and/or a prominent notice on our Service, prior to the change becoming effective and update “effective date” at the top of this Privacy Policy.\n\nYou are advised to review this Privacy Policy periodically for any changes. Changes to this Privacy Policy are effective when they are posted on this page.\n\n17. Contact Us\n\nIf you have any questions about this Privacy Policy, please contact us by email: zrytezene@gmail.com.\n\n\nDISCLAIMER\nLast updated: 2020-04-05\n\nWEBSITE DISCLAIMER\n\nThe information provided by ZryteZene (“Company”, “we”, “our”, “us”) on https://zrytezene.web.app (the “Site”) is for general informational purposes only. All information on the Site is provided in good faith, however we make no representation or warranty of any kind, express or implied, regarding the accuracy, adequacy, validity, reliability, availability, or completeness of any information on the Site.\n\nUNDER NO CIRCUMSTANCE SHALL WE HAVE ANY LIABILITY TO YOU FOR ANY LOSS OR DAMAGE OF ANY KIND INCURRED AS A RESULT OF THE USE OF THE SITE OR RELIANCE ON ANY INFORMATION PROVIDED ON THE SITE. YOUR USE OF THE SITE AND YOUR RELIANCE ON ANY INFORMATION ON THE SITE IS SOLELY AT YOUR OWN RISK.\n\nEXTERNAL LINKS DISCLAIMER\n\nThe Site may contain (or you may be sent through the Site) links to other websites or content belonging to or originating from third parties or links to websites and features. Such external links are not investigated, monitored, or checked for accuracy, adequacy, validity, reliability, availability or completeness by us.\n\nFor example, the outlined Disclaimer has been created using PolicyMaker.io, a free web application for generating high-quality legal documents. PolicyMaker’s free website Disclaimer generator is an easy-to-use tool for creating an excellent Disclaimer template for a website, blog, eCommerce store or app.\n\nWE DO NOT WARRANT, ENDORSE, GUARANTEE, OR ASSUME RESPONSIBILITY FOR THE ACCURACY OR RELIABILITY OF ANY INFORMATION OFFERED BY THIRD-PARTY WEBSITES LINKED THROUGH THE SITE OR ANY WEBSITE OR FEATURE LINKED IN ANY BANNER OR OTHER ADVERTISING. WE WILL NOT BE A PARTY TO OR IN ANY WAY BE RESPONSIBLE FOR MONITORING ANY TRANSACTION BETWEEN YOU AND THIRD-PARTY PROVIDERS OF PRODUCTS OR SERVICES.\n\nAFFILIATES DISCLAIMER\n\nThe Site may contain links to affiliate websites, and we may receive an affiliate commission for any purchases or actions made by you on the affiliate websites using such links.\n\nERRORS AND OMISSIONS DISCLAIMER\n\nWhile we have made every attempt to ensure that the information contained in this site has been obtained from reliable sources, ZryteZene is not responsible for any errors or omissions or for the results obtained from the use of this information. All information in this site is provided “as is”, with no guarantee of completeness, accuracy, timeliness or of the results obtained from the use of this information, and without warranty of any kind, express or implied, including, but not limited to warranties of performance, merchantability, and fitness for a particular purpose.\n\nIn no event will ZryteZene, its related partnerships or corporations, or the partners, agents or employees thereof be liable to you or anyone else for any decision made or action taken in reliance on the information in this Site or for any consequential, special or similar damages, even if advised of the possibility of such damages.\n\nGUEST CONTRIBUTORS DISCLAIMER\n\nThis Site may include content from guest contributors and any views or opinions expressed in such posts are personal and do not represent those of ZryteZene or any of its staff or affiliates unless explicitly stated.\n\nLOGOS AND TRADEMARKS DISCLAIMER\n\nAll logos and trademarks of third parties referenced on https://zrytezene.web.app are the trademarks and logos of their respective owners. Any inclusion of such trademarks or logos does not imply or constitute any approval, endorsement or sponsorship of ZryteZene by such owners.\n\nCONTACT US\n\nShould you have any feedback, comments, requests for technical support or other inquiries, please contact us by email: zrytezene@gmail.com.\n"); - _nextSetup(); - } - - @Override - public void onStart() { - super.onStart(); - - } - - @Override - public void onResume() { - super.onResume(); - - } - - @Override - public void onPause() { - super.onPause(); - - } - - @Override - public void onStop() { - super.onStop(); - - } - - @Override - public void onBackPressed() { - - } - - private void _BlackStatusBarIcons() { - getWindow().setStatusBarColor(Color.parseColor("#FFFFFF")); - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - } - - private void _CoreProgressLoading(final boolean _ifShow) { - if (_ifShow) { - if (coreprog == null) { - coreprog = new ProgressDialog(this); - coreprog.setCancelable(false); - coreprog.setCanceledOnTouchOutside(false); - - coreprog.requestWindowFeature(Window.FEATURE_NO_TITLE); - coreprog.getWindow().setBackgroundDrawable(new android.graphics.drawable.ColorDrawable(Color.TRANSPARENT)); - - } - coreprog.setMessage(null); - coreprog.show(); - LayoutInflater _inflater = (LayoutInflater) getBaseContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); - View _coreView = _inflater.inflate(R.layout.custom_dialog, null); - final ImageView imageview1 = _coreView.findViewById(R.id.imageview1); - com.bumptech.glide.Glide.with(getApplicationContext()).load(R.raw.partyblob).into(imageview1); - coreprog.setContentView(_coreView); - } else { - if (coreprog != null) { - coreprog.dismiss(); - } - } - } - - private void _setFont() { - Typeface tpf = Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"); - textview2.setTypeface(tpf, 0); - textview3.setTypeface(tpf, 0); - textview4.setTypeface(tpf, 0); - textview5.setTypeface(tpf, 0); - textview6.setTypeface(tpf, 0); - textview7.setTypeface(tpf, 0); - textview8.setTypeface(tpf, 0); - edittext1.setTypeface(tpf, 0); - textview9.setTypeface(tpf, 0); - edittext2.setTypeface(tpf, 0); - textview10.setTypeface(tpf, 0); - button1.setTypeface(tpf, 0); - textview11.setTypeface(tpf, 0); - textview12.setTypeface(tpf, 0); - textview13.setTypeface(tpf, 0); - checkbox1.setTypeface(tpf, 0); - button2.setTypeface(tpf, 0); - } - - private void _nextSetup() { - currentSetup++; - if (currentSetup < 5) { - linear2.setVisibility(View.GONE); - linear6.setVisibility(View.GONE); - linear10.setVisibility(View.GONE); - linear17.setVisibility(View.GONE); - _fab.hide(); - if (currentSetup==1) { - linear2.setVisibility(View.VISIBLE); - _customNav("#FFFFFF"); - _BlackStatusBarIcons(); - _fab.show(); - } - if (currentSetup==2) { - linear6.setVisibility(View.VISIBLE); - _customNav("#FFFFFF"); - getWindow().getDecorView().setSystemUiVisibility(0); - getWindow().setStatusBarColor(Color.parseColor("#3F51B5")); - } - if (currentSetup==3) { - linear10.setVisibility(View.VISIBLE); - _customNav("#FFFFFF"); - getWindow().getDecorView().setSystemUiVisibility(0); - getWindow().setStatusBarColor(Color.parseColor("#2196F3")); - } - if (currentSetup==4) { - linear17.setVisibility(View.VISIBLE); - _customNav("#FFFFFF"); - _BlackStatusBarIcons(); - } - } else { - data.edit().putString("setup", "1").commit(); - data.edit().putString("license", "1").commit(); - intent.setClass(getApplicationContext(), MainActivity.class); - startActivity(intent); - finish(); - } - } - - - private void _customNav(final String _color) { - this.getWindow().setNavigationBarColor(Color.parseColor(_color)); - } - - - private void _shape(final double _tl, final double _tr, final double _bl, final double _br, final String _BGcolor, final String _Scolor, final double _Swidth, final View _view) { - Double tlr = _tl; - Double trr = _tr; - Double blr = _bl; - Double brr = _br; - Double sw = _Swidth; - android.graphics.drawable.GradientDrawable s = new android.graphics.drawable.GradientDrawable(); - s.setShape(android.graphics.drawable.GradientDrawable.RECTANGLE); - s.setCornerRadii(new float[]{tlr.floatValue(), tlr.floatValue(), trr.floatValue(), trr.floatValue(), blr.floatValue(), blr.floatValue(), brr.floatValue(), brr.floatValue()}); - s.setColor(Color.parseColor(_BGcolor)); - s.setStroke(sw.intValue(), Color.parseColor(_Scolor)); - _view.setBackground(s); - } - - - private void _shadow(final View _v, final double _n) { - _v.setElevation((float) _n); - } - - - private void _grantPermission() { - if (checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) { - showMessage("Please allow the notification settings"); - Intent opd = new Intent(Settings.ACTION_APP_NOTIFICATION_SETTINGS); - opd.putExtra(Settings.EXTRA_APP_PACKAGE, getPackageName()); - startActivity(opd); - } else { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) { - if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) != PackageManager.PERMISSION_GRANTED) { - ActivityCompat.requestPermissions(this, new String[]{android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK}, 1001); - } else { - _nextSetup(); - } - } else { - _nextSetup(); - } - } - } - - @Override - public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == 1001) { - if (ContextCompat.checkSelfPermission(getApplicationContext(), android.Manifest.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK) != PackageManager.PERMISSION_GRANTED) { - _customSnack("Please tap \"Grant\" to continue.", 0); - } else { - button2.setText("Next"); - } - } - } - - - private void _resetDialog() { - dialog = null; - dialog = new AlertDialog.Builder(this); - } - - - private void _customSnack(final String _txt, final double _icon) { - ViewGroup containerLayout = (ViewGroup) ((ViewGroup) this.findViewById(android.R.id.content)).getChildAt(0); - com.google.android.material.snackbar.Snackbar snackbar = com.google.android.material.snackbar.Snackbar.make(containerLayout, "", com.google.android.material.snackbar.Snackbar.LENGTH_LONG); - com.google.android.material.snackbar.Snackbar.SnackbarLayout layout = (com.google.android.material.snackbar.Snackbar.SnackbarLayout) snackbar.getView(); - View snackview = getLayoutInflater().inflate(R.layout.custom_snack, null); - ImageView image = snackview.findViewById(R.id.imageview); - if (_icon == 0) { - image.setImageResource(R.drawable.ic_info_outline_white); - layout.setBackgroundColor(Color.parseColor("#2090F0")); - } else { - if (_icon == 1) { - image.setImageResource(R.drawable.ic_done_white); - layout.setBackgroundColor(Color.parseColor("#48B048")); - } else { - if (_icon == 2) { - image.setImageResource(R.drawable.ic_exit_white); - layout.setBackgroundColor(Color.parseColor("#E03830")); - } - } - } - TextView text = snackview.findViewById(R.id.textview); - text.setText(_txt); - text.setTextColor(Color.WHITE); - text.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/googlesans.ttf"), 0); - layout.setPadding(0, 0, 0, 0); - layout.addView(snackview, 0); - snackbar.show(); - } - - - private void _rippleLib() { - } - - public void drawableclass() { - } - - private void _rippleEffect(final View _view, final String _color) { - _view.setBackground(Drawables.getSelectableDrawableFor(Color.parseColor(_color))); - _view.setClickable(true); - } - - private void _abandonFocus() { - View _tmpView = this.getCurrentFocus(); - if (_tmpView != null) { - android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(_tmpView.getWindowToken(), 0); - } - } - - private void _nxtStep() { - - } - - @Deprecated - public void showMessage(String _s) { - Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show(); - } - - @Deprecated - public int getLocationX(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[0]; - } - - @Deprecated - public int getLocationY(View _v) { - int[] _location = new int[2]; - _v.getLocationInWindow(_location); - return _location[1]; - } - - @Deprecated - public int getRandom(int _min, int _max) { - Random random = new Random(); - return random.nextInt(_max - _min + 1) + _min; - } - - @Deprecated - public float getDip(int _input) { - return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics()); - } - - @Deprecated - public int getDisplayWidthPixels() { - return getResources().getDisplayMetrics().widthPixels; - } - - @Deprecated - public int getDisplayHeightPixels() { - return getResources().getDisplayMetrics().heightPixels; - } - - public static class Drawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[8]; - Arrays.fill(outerRadii, 0); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - - public static class CircleDrawables { - public static android.graphics.drawable.Drawable getSelectableDrawableFor(int color) { - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { - android.graphics.drawable.StateListDrawable stateListDrawable = new android.graphics.drawable.StateListDrawable(); - stateListDrawable.addState( - new int[]{android.R.attr.state_pressed}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#ffffff")) - ); - stateListDrawable.addState( - new int[]{android.R.attr.state_focused}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - stateListDrawable.addState( - new int[]{}, - new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")) - ); - return stateListDrawable; - } else { - android.content.res.ColorStateList pressedColor = android.content.res.ColorStateList.valueOf(color); - android.graphics.drawable.ColorDrawable defaultColor = new android.graphics.drawable.ColorDrawable(Color.parseColor("#00ffffff")); - - android.graphics.drawable.Drawable rippleColor = getRippleColor(color); - return new android.graphics.drawable.RippleDrawable( - pressedColor, - defaultColor, - rippleColor - ); - } - } - - private static android.graphics.drawable.Drawable getRippleColor(int color) { - float[] outerRadii = new float[180]; - Arrays.fill(outerRadii, 80); - android.graphics.drawable.shapes.RoundRectShape r = new android.graphics.drawable.shapes.RoundRectShape(outerRadii, null, null); - - android.graphics.drawable.ShapeDrawable shapeDrawable = new - android.graphics.drawable.ShapeDrawable(r); - shapeDrawable.getPaint().setColor(color); - return shapeDrawable; - } - - private static int lightenOrDarken(int color, double fraction) { - if (canLighten(color, fraction)) { - return lighten(color, fraction); - } else { - return darken(color, fraction); - } - } - - private static int lighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = lightenColor(red, fraction); - green = lightenColor(green, fraction); - blue = lightenColor(blue, fraction); - int alpha = Color.alpha(color); - return Color.argb(alpha, red, green, blue); - } - - private static int darken(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - red = darkenColor(red, fraction); - green = darkenColor(green, fraction); - blue = darkenColor(blue, fraction); - int alpha = Color.alpha(color); - - return Color.argb(alpha, red, green, blue); - } - - private static boolean canLighten(int color, double fraction) { - int red = Color.red(color); - int green = Color.green(color); - int blue = Color.blue(color); - return canLightenComponent(red, fraction) - && canLightenComponent(green, fraction) - && canLightenComponent(blue, fraction); - } - - private static boolean canLightenComponent(int colorComponent, double fraction) { - int red = Color.red(colorComponent); - int green = Color.green(colorComponent); - int blue = Color.blue(colorComponent); - return red + (red * fraction) < 255 - && green + (green * fraction) < 255 - && blue + (blue * fraction) < 255; - } - - private static int darkenColor(int color, double fraction) { - return (int) Math.max(color - (color * fraction), 0); - } - - private static int lightenColor(int color, double fraction) { - return (int) Math.min(color + (color * fraction), 255); - } - } - -} diff --git a/app/src/main/java/tw/music/streamer/adapter/ZZChatAdapter.java b/app/src/main/java/tw/music/streamer/adapter/ZZChatAdapter.java new file mode 100644 index 0000000..a728c19 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/adapter/ZZChatAdapter.java @@ -0,0 +1,59 @@ +package tw.music.streamer.adapter; + +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.TextView; +import android.widget.ImageView; +import android.widget.LinearLayout; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; +import java.util.ArrayList; + +import tw.music.streamer.R; + +import tw.music.streamer.loader.ZryteZeneImageLoader; +import tw.music.streamer.adaptor.ZZChat; + +public class ZZChatAdapter extends RecyclerView.Adapter { + + private ArrayList data; + + public ZZChatAdapter(ArrayList a) { + data = a; + } + + @NonNull + @Override + public ZZViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.chat_item_1, parent, false); + return new ZZViewHolder(view); + } + + @Override + public void onBindViewHolder(@NonNull ZZViewHolder h, final int p) { + h.name.setText(data.get(p).name); + h.signature.setText(data.get(p).timestamp + " - listening to " + data.get(p).last_song); + h.msg.setText(data.get(p).message); + ZryteZeneImageLoader.getInstance(h.name.getContext()).load(data.get(p).photo, h.pp); + } + + @Override + public int getItemCount() { + return data.size(); + } + + public static class ZZViewHolder extends RecyclerView.ViewHolder { + TextView name, signature, msg; + ImageView pp; + + public ZZViewHolder(@NonNull View i) { + super(i); + name = i.findViewById(R.id.user_name); + signature = i.findViewById(R.id.user_signature); + msg = i.findViewById(R.id.user_msg); + pp = i.findViewById(R.id.user_pp); + } + } + +} diff --git a/app/src/main/java/tw/music/streamer/adapter/ZZRandomSongAdapter.java b/app/src/main/java/tw/music/streamer/adapter/ZZRandomSongAdapter.java index 1110ecb..7811f62 100644 --- a/app/src/main/java/tw/music/streamer/adapter/ZZRandomSongAdapter.java +++ b/app/src/main/java/tw/music/streamer/adapter/ZZRandomSongAdapter.java @@ -15,15 +15,16 @@ import tw.music.streamer.R; import tw.music.streamer.adaptor.ZZSong; -import com.bumptech.glide.Glide; -import com.bumptech.glide.load.engine.DiskCacheStrategy; +import tw.music.streamer.loader.ZryteZeneImageLoader; public class ZZRandomSongAdapter extends RecyclerView.Adapter { private ArrayList data; + private ZZOnClickListener listener; - public ZZRandomSongAdapter(ArrayList a) { + public ZZRandomSongAdapter(ArrayList a, ZZOnClickListener b) { data = a; + listener = b; } @NonNull @@ -37,7 +38,13 @@ public ZZViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) public void onBindViewHolder(@NonNull ZZViewHolder h, int p) { h.title.setText(data.get(p).song_name); h.line.setBackgroundColor(Color.parseColor(data.get(p).color1)); - Glide.with(h.title.getContext()).load(data.get(p).url_cover).diskCacheStrategy(DiskCacheStrategy.ALL).into(h.cover); + ZryteZeneImageLoader.getInstance(h.title.getContext()).load(data.get(p).url_cover, h.cover); + h.cover.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View a) { + callListener(p); + } + }); } @Override @@ -57,4 +64,10 @@ public ZZViewHolder(@NonNull View i) { line = i.findViewById(R.id.sli2_bottom_line); } } + + public void callListener(int a) { + if (listener!=null) { + listener.onItemClicked(a); + } + } } diff --git a/app/src/main/java/tw/music/streamer/adapter/ZZSongAdapter.java b/app/src/main/java/tw/music/streamer/adapter/ZZSongAdapter.java index ddd3f5e..9a70dc7 100644 --- a/app/src/main/java/tw/music/streamer/adapter/ZZSongAdapter.java +++ b/app/src/main/java/tw/music/streamer/adapter/ZZSongAdapter.java @@ -14,8 +14,7 @@ import tw.music.streamer.R; import tw.music.streamer.adaptor.ZZSong; -import com.bumptech.glide.Glide; -import com.bumptech.glide.load.engine.DiskCacheStrategy; +import tw.music.streamer.loader.ZryteZeneImageLoader; public class ZZSongAdapter extends RecyclerView.Adapter { @@ -38,7 +37,7 @@ public ZZViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) public void onBindViewHolder(@NonNull ZZViewHolder h, final int p) { h.title.setText(data.get(p).song_name); h.artist.setText(data.get(p).song_artist); - Glide.with(h.title.getContext()).load(data.get(p).url_cover).diskCacheStrategy(DiskCacheStrategy.ALL).into(h.cover); + ZryteZeneImageLoader.getInstance(h.title.getContext()).load(data.get(p).url_cover, h.cover); h.cover.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View a) { diff --git a/app/src/main/java/tw/music/streamer/adaptor/ZZChat.java b/app/src/main/java/tw/music/streamer/adaptor/ZZChat.java new file mode 100644 index 0000000..8abeae2 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/adaptor/ZZChat.java @@ -0,0 +1,18 @@ +package tw.music.streamer.adaptor; + +import com.google.firebase.database.DataSnapshot; + +public class ZZChat { + + public String key, name, message, last_song, timestamp, photo; + public int time; + + public ZZChat(DataSnapshot a) { + key = a.getKey(); + name = a.child("f").getValue(String.class); + message = a.child("m").getValue(String.class); + last_song = a.child("ls").getValue(String.class); + timestamp = a.child("ts").getValue(String.class); + photo = a.child("p").getValue(String.class); + } +} diff --git a/app/src/main/java/tw/music/streamer/adaptor/ZZSong.java b/app/src/main/java/tw/music/streamer/adaptor/ZZSong.java index 2930e5e..a0c839c 100644 --- a/app/src/main/java/tw/music/streamer/adaptor/ZZSong.java +++ b/app/src/main/java/tw/music/streamer/adaptor/ZZSong.java @@ -7,10 +7,11 @@ public class ZZSong { public static final String PATH = "https://firebasestorage.googleapis.com/v0/b/teammusic-tw.appspot.com/o/zrytezene%2Fsongs%2F"; public String key, url_song, url_icon, url_cover, uploader_uid, uploader_name, song_name, song_artist, color1; - public boolean playing; + public boolean playing, cl; public ZZSong(DataSnapshot a) { playing = false; + cl = false; key = a.getKey(); url_song = PATH + a.child("song").getValue(String.class); url_icon = PATH + a.child("icon").getValue(String.class); diff --git a/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneAdaptor.java b/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneAdaptor.java index d607f04..16db704 100644 --- a/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneAdaptor.java +++ b/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneAdaptor.java @@ -13,7 +13,7 @@ public class ZryteZeneAdaptor { private int cd, bu, d; private ArrayList e; private Context ctx; - private String sp, n; + private String sp, n, sk; public ZryteZeneAdaptor(Context a) { isr = false; @@ -74,6 +74,14 @@ public int getBufferingUpdate() { return bu; } + public void setKey(String a) { + sk = a; + } + + public String getKey() { + return sk; + } + public void clear() { requestAction("stop","-"); } diff --git a/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneSongsManager.java b/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneSongsManager.java index 9a2e9b1..3fe7b16 100644 --- a/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneSongsManager.java +++ b/app/src/main/java/tw/music/streamer/adaptor/ZryteZeneSongsManager.java @@ -53,6 +53,7 @@ protected Boolean doInBackground(Void... voids) { storageRef.getFile(tempFile).addOnSuccessListener(taskSnapshot -> { try { InputStream input = context.getContentResolver().openInputStream(android.net.Uri.fromFile(tempFile)); + if (songFile.exists()) songFile.delete(); FileOutputStream output = new FileOutputStream(songFile); byte[] buffer = new byte[4096]; int length; diff --git a/app/src/main/java/tw/music/streamer/loader/ZryteZeneImageLoader.java b/app/src/main/java/tw/music/streamer/loader/ZryteZeneImageLoader.java new file mode 100644 index 0000000..b1a1e25 --- /dev/null +++ b/app/src/main/java/tw/music/streamer/loader/ZryteZeneImageLoader.java @@ -0,0 +1,244 @@ +package tw.music.streamer.loader; + +import android.content.Context; +import android.os.Handler; +import android.os.Looper; +import android.widget.ImageView; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.RectF; +import android.graphics.Shader; +import android.graphics.BitmapShader; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.collection.LruCache; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ZryteZeneImageLoader { + + public static interface BitmapCallback { + void onBitmapLoaded(@Nullable Bitmap bitmap); + } + + private static ZryteZeneImageLoader instance; + private final LruCache memoryCache; + private final ExecutorService executorService; + private final File cacheDir; + private final Handler mainHandler = new Handler(Looper.getMainLooper()); + + private ZryteZeneImageLoader(Context context) { + final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); + final int cacheSize = maxMemory / 8; + memoryCache = new LruCache(cacheSize) { + @Override + protected int sizeOf(@NonNull String key, @NonNull Bitmap bitmap) { + return bitmap.getByteCount() / 1024; + } + }; + executorService = Executors.newFixedThreadPool(4); + cacheDir = new File(context.getFilesDir(), "images-cache"); + if (!cacheDir.exists()) cacheDir.mkdirs(); + preloadDiskCache(); + } + + public static synchronized ZryteZeneImageLoader getInstance(Context context) { + if (instance == null) instance = new ZryteZeneImageLoader(context.getApplicationContext()); + return instance; + } + + public void load(String url, ImageView imageView) { + load(url, imageView, null); + } + + public void load(String url, @Nullable BitmapCallback callback) { + Bitmap cachedBitmap = memoryCache.get(String.valueOf(url.hashCode())); + if (cachedBitmap != null) { + if (callback != null) callback.onBitmapLoaded(cachedBitmap); + return; + } + executorService.execute(() -> { + Bitmap bitmap = loadFromDiskCache(String.valueOf(url.hashCode())); + if (bitmap == null) { + bitmap = loadFromNetwork(url); + if (bitmap != null) saveToDiskCache(url, bitmap); + } + final Bitmap resultBitmap = bitmap; + mainHandler.post(() -> { + if (callback != null) callback.onBitmapLoaded(resultBitmap); + }); + }); + } + + public void load(String url, ImageView imageView, @Nullable BitmapCallback callback) { + imageView.setTag(url); + Bitmap cachedBitmap = memoryCache.get(String.valueOf(url.hashCode())); + if (cachedBitmap != null) { + imageView.setImageBitmap(cachedBitmap); + if (callback != null) callback.onBitmapLoaded(cachedBitmap); + return; + } + executorService.execute(() -> { + Bitmap bitmap = loadFromDiskCache(String.valueOf(url.hashCode())); + if (bitmap == null) { + bitmap = loadFromNetwork(url); + if (bitmap != null) saveToDiskCache(url, bitmap); + } + final Bitmap resultBitmap = bitmap; + mainHandler.post(() -> { + if (imageView.getTag().equals(url) && resultBitmap != null) imageView.setImageBitmap(resultBitmap); + if (callback != null) callback.onBitmapLoaded(resultBitmap); + }); + }); + } + + public void loadWithCircularOutput(String url, ImageView imageView) { + imageView.setTag(url); + Bitmap cachedBitmap = memoryCache.get(String.valueOf("circular-" + url.hashCode())); + if (cachedBitmap != null) { + imageView.setImageBitmap(cachedBitmap); + return; + } + executorService.execute(() -> { + Bitmap bitmap = loadFromDiskCache(String.valueOf("circular-" + url.hashCode())); + if (bitmap == null) { + bitmap = createCircularBitmap(loadFromNetwork(url)); + if (bitmap != null) saveToDiskCache("circular-" + url, bitmap); + } + final Bitmap resultBitmap = bitmap; + mainHandler.post(() -> { + if (imageView.getTag().equals(url) && resultBitmap != null) imageView.setImageBitmap(resultBitmap); + }); + }); + } + + public void loadWithRoundOutput(String url, ImageView imageView, final float round) { + imageView.setTag(url); + Bitmap cachedBitmap = createRoundedCornerBitmap(memoryCache.get(String.valueOf(url.hashCode())), round); + if (cachedBitmap != null) { + imageView.setImageBitmap(cachedBitmap); + return; + } + executorService.execute(() -> { + Bitmap bitmap = loadFromDiskCache(String.valueOf(url.hashCode())); + if (bitmap == null) { + bitmap = loadFromNetwork(url); + if (bitmap != null) saveToDiskCache(url, bitmap); + } + final Bitmap resultBitmap = createRoundedCornerBitmap(bitmap, round); + mainHandler.post(() -> { + if (imageView.getTag().equals(url) && resultBitmap != null) imageView.setImageBitmap(resultBitmap); + }); + }); + } + + private Bitmap loadFromNetwork(String urlString) { + try { + URL url = new URL(urlString); + HttpURLConnection connection = (HttpURLConnection) url.openConnection(); + connection.setConnectTimeout(5000); + connection.setReadTimeout(5000); + connection.connect(); + if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) { + InputStream inputStream = connection.getInputStream(); + Bitmap bitmap = BitmapFactory.decodeStream(inputStream); + inputStream.close(); + memoryCache.put(urlString, bitmap); + return bitmap; + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private Bitmap loadFromDiskCache(String url) { + try { + File file = new File(cacheDir, String.valueOf(url.hashCode())); + if (file.exists()) { + Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); + if (bitmap != null) memoryCache.put(url, bitmap); + return bitmap; + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private void saveToDiskCache(String url, Bitmap bitmap) { + try { + File file = new File(cacheDir, String.valueOf(url.hashCode())); + FileOutputStream fos = new FileOutputStream(file); + bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos); + fos.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void clearCache() { + memoryCache.evictAll(); + File[] files = cacheDir.listFiles(); + if (files != null) { + for (File file : files) { + file.delete(); + } + } + } + + private void preloadDiskCache() { + File[] cachedFiles = cacheDir.listFiles(); + if (cachedFiles != null) { + for (File file : cachedFiles) { + executorService.execute(() -> { + try { + Bitmap bitmap = BitmapFactory.decodeFile(file.getAbsolutePath()); + if (bitmap != null) { + memoryCache.put(file.getName(), bitmap); + } + } catch (Exception e) { + e.printStackTrace(); + } + }); + } + } + } + + private Bitmap createCircularBitmap(Bitmap bitmap) { + if (bitmap == null) return null; + int size = Math.min(bitmap.getWidth(), bitmap.getHeight()); + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(output); + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + float radius = size / 2f; + BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + paint.setShader(shader); + canvas.drawCircle(bitmap.getWidth()/2, bitmap.getHeight()/2, radius, paint); + if (!bitmap.isRecycled()) bitmap.recycle(); + return output; + } + + private Bitmap createRoundedCornerBitmap(Bitmap bitmap, float cornerRadius) { + if (bitmap == null) return null; + Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Bitmap.Config.ARGB_8888); + Canvas canvas = new Canvas(output); + Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); + BitmapShader shader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); + paint.setShader(shader); + RectF rect = new RectF(0, 0, bitmap.getWidth(), bitmap.getHeight()); + canvas.drawRoundRect(rect, cornerRadius, cornerRadius, paint); + if (!bitmap.isRecycled()) bitmap.recycle(); + return output; + } + +} \ No newline at end of file diff --git a/app/src/main/java/tw/music/streamer/notification/ZryteZeneNotification.java b/app/src/main/java/tw/music/streamer/notification/ZryteZeneNotification.java index ddf46c0..0a08042 100644 --- a/app/src/main/java/tw/music/streamer/notification/ZryteZeneNotification.java +++ b/app/src/main/java/tw/music/streamer/notification/ZryteZeneNotification.java @@ -20,10 +20,7 @@ import android.support.v4.media.session.MediaSessionCompat; -import com.bumptech.glide.Glide; -import com.bumptech.glide.request.target.CustomTarget; -import com.bumptech.glide.request.transition.Transition; -import com.bumptech.glide.load.engine.DiskCacheStrategy; +import tw.music.streamer.loader.ZryteZeneImageLoader; import tw.music.streamer.receiver.ZryteZeneBroadcastReceiver; import tw.music.streamer.service.ZryteZenePlay; @@ -48,19 +45,9 @@ public static void update(Context a, boolean b, MediaSessionCompat c, String d, if (f.equals("-")) { updateWithMedia(a,b,c,d,e,null,g); } else { - Glide.with(a) - .asBitmap() - .load(f) - .diskCacheStrategy(DiskCacheStrategy.ALL) - .into(new CustomTarget() { - @Override - public void onResourceReady(@NonNull Bitmap h, @NonNull Transition i) { - updateWithMedia(a,b,c,d,e,h,g); - } - @Override - public void onLoadCleared(@Nullable Drawable j) { - } - }); + ZryteZeneImageLoader.getInstance(a).load(f, bitmap -> { + if (bitmap!=null) updateWithMedia(a,b,c,d,e,bitmap,g); + }); } } diff --git a/app/src/main/java/tw/music/streamer/service/ZryteZenePlay.java b/app/src/main/java/tw/music/streamer/service/ZryteZenePlay.java index 8fe1559..58f3f21 100644 --- a/app/src/main/java/tw/music/streamer/service/ZryteZenePlay.java +++ b/app/src/main/java/tw/music/streamer/service/ZryteZenePlay.java @@ -268,6 +268,7 @@ private void tellActivity(String a, int b) { ita = new Intent(ACTION_UPDATE); ita.putExtra("update", a); ita.putExtra("data", b); + ita.putExtra("key", sk); sendBroadcast(ita); } diff --git a/app/src/main/res/drawable-xhdpi/discord.png b/app/src/main/res/drawable-xhdpi/discord.png new file mode 100644 index 0000000..0628ea0 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/discord.png differ diff --git a/app/src/main/assets/fonts/googlesans.ttf b/app/src/main/res/font/googlesans.ttf similarity index 100% rename from app/src/main/assets/fonts/googlesans.ttf rename to app/src/main/res/font/googlesans.ttf diff --git a/app/src/main/assets/fonts/googlesansbold.ttf b/app/src/main/res/font/googlesansbold.ttf similarity index 100% rename from app/src/main/assets/fonts/googlesansbold.ttf rename to app/src/main/res/font/googlesansbold.ttf diff --git a/app/src/main/res/layout/_drawer_filepicker.xml b/app/src/main/res/layout/_drawer_filepicker.xml deleted file mode 100644 index d5d3617..0000000 --- a/app/src/main/res/layout/_drawer_filepicker.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/_drawer_streamer.xml b/app/src/main/res/layout/_drawer_streamer.xml deleted file mode 100644 index 6ff501b..0000000 --- a/app/src/main/res/layout/_drawer_streamer.xml +++ /dev/null @@ -1,375 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/about.xml b/app/src/main/res/layout/about.xml deleted file mode 100644 index 7549147..0000000 --- a/app/src/main/res/layout/about.xml +++ /dev/null @@ -1,1126 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/chat_item_1.xml b/app/src/main/res/layout/chat_item_1.xml new file mode 100644 index 0000000..4f9a5b0 --- /dev/null +++ b/app/src/main/res/layout/chat_item_1.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/chgpic.xml b/app/src/main/res/layout/chgpic.xml deleted file mode 100644 index 40aac9a..0000000 --- a/app/src/main/res/layout/chgpic.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/colpick.xml b/app/src/main/res/layout/colpick.xml deleted file mode 100644 index c5ba9fb..0000000 --- a/app/src/main/res/layout/colpick.xml +++ /dev/null @@ -1,303 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/comments_layout.xml b/app/src/main/res/layout/comments_layout.xml deleted file mode 100644 index ba050b2..0000000 --- a/app/src/main/res/layout/comments_layout.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/crop.xml b/app/src/main/res/layout/crop.xml deleted file mode 100644 index 1b0560c..0000000 --- a/app/src/main/res/layout/crop.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - - - -