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