From c4e8167efcb14aae439c44f0e8e010a9acfccbb6 Mon Sep 17 00:00:00 2001 From: massi Date: Sat, 29 Oct 2022 02:01:02 +0200 Subject: [PATCH] Added Cryptpad Removed Calc Removed Polls Refractor Improved ui state --- README.md | 2 +- app/src/main/AndroidManifest.xml | 5 +- .../disrootapp/StatusBroadcastReceiver.java | 2 + .../org/disroot/disrootapp/StatusService.java | 16 +- .../disroot/disrootapp/ui/AboutActivity.java | 155 +++++------ .../disroot/disrootapp/ui/MainActivity.java | 110 +++----- .../disrootapp/ui/SettingsActivity.java | 247 +++++++----------- .../disroot/disrootapp/ui/StateActivity.java | 103 ++------ .../disrootapp/ui/StateMessagesActivity.java | 98 +++---- .../disrootapp/ui/WelcomeActivity.java | 25 +- .../disroot/disrootapp/utils/Constants.java | 11 +- .../drawable/{ic_calc.xml => ic_cryptpad.xml} | 0 app/src/main/res/drawable/ic_poll.xml | 15 -- app/src/main/res/layout/activity_main.xml | 16 +- app/src/main/res/layout/activity_settings.xml | 28 +- .../res/layout/fragment_about_license.xml | 4 +- ...ist_item.xml => list_service_messages.xml} | 41 +-- app/src/main/res/layout/list_services.xml | 38 +++ app/src/main/res/values-de/strings.xml | 17 +- app/src/main/res/values-es/strings.xml | 18 +- app/src/main/res/values-fr/strings.xml | 18 +- app/src/main/res/values-it/strings.xml | 18 +- app/src/main/res/values-nl/strings.xml | 18 +- app/src/main/res/values-pt-rBR/strings.xml | 18 +- app/src/main/res/values-pt/strings.xml | 18 +- app/src/main/res/values-sr/strings.xml | 18 +- app/src/main/res/values/strings.xml | 27 +- app/src/main/res/xml/changelog_master.xml | 7 +- metadata/de-DE/full_description.txt | 2 +- metadata/en-US/full_description.txt | 2 +- metadata/es-ES/full_description.txt | 2 +- metadata/fr-FR/full_description.txt | 2 +- metadata/it-IT/full_description.txt | 2 +- metadata/nl-NL/full_description.txt | 2 +- metadata/sr-SR/full_description.txt | 2 +- 35 files changed, 430 insertions(+), 677 deletions(-) rename app/src/main/res/drawable/{ic_calc.xml => ic_cryptpad.xml} (100%) delete mode 100644 app/src/main/res/drawable/ic_poll.xml rename app/src/main/res/layout/{list_item.xml => list_service_messages.xml} (76%) create mode 100644 app/src/main/res/layout/list_services.xml diff --git a/README.md b/README.md index 56ab393..3744595 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It also can be used to access all the **Disroot** services that do not require an account: * Etherpad -* Ethercalc +* Cryptpad * Calls * Private bin * Upload diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index a8a7df7..9bc455a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -64,14 +64,11 @@ android:host="forum.disroot.org" android:scheme="https" /> - diff --git a/app/src/main/java/org/disroot/disrootapp/StatusBroadcastReceiver.java b/app/src/main/java/org/disroot/disrootapp/StatusBroadcastReceiver.java index fb9d2c3..cc3703b 100644 --- a/app/src/main/java/org/disroot/disrootapp/StatusBroadcastReceiver.java +++ b/app/src/main/java/org/disroot/disrootapp/StatusBroadcastReceiver.java @@ -1,11 +1,13 @@ package org.disroot.disrootapp; +import android.annotation.SuppressLint; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; public class StatusBroadcastReceiver extends BroadcastReceiver { + @SuppressLint("UnsafeProtectedBroadcastReceiver") @Override public void onReceive(Context context, Intent intent) { diff --git a/app/src/main/java/org/disroot/disrootapp/StatusService.java b/app/src/main/java/org/disroot/disrootapp/StatusService.java index 9420321..15e3cf4 100644 --- a/app/src/main/java/org/disroot/disrootapp/StatusService.java +++ b/app/src/main/java/org/disroot/disrootapp/StatusService.java @@ -37,7 +37,7 @@ public class StatusService extends Service { //status report public SharedPreferences checkDate; // URL to get data JSON - static String incidenturl0 ="https://status.disroot.org/issues/index.json"; + static String incidentUrl0 ="https://status.disroot.org/issues/index.json"; ArrayList> messageList; ArrayList> getDate; @@ -78,13 +78,13 @@ public class StatusService extends Service { protected Void doInBackground(Void... arg0) { HttpHandler sh = new HttpHandler(); - String jsonStrincidents0 = sh.makeServiceCall(incidenturl0); + String jsonStringIdents0 = sh.makeServiceCall( incidentUrl0 ); - Log.e(TAG, "Response from url(Service): " + incidenturl0); + Log.e(TAG, "Response from url(Service): " + incidentUrl0 ); - if (jsonStrincidents0 != null) {//Incidaetnts page + if (jsonStringIdents0 != null) {//Incidents page try { - JSONObject jsonObj = new JSONObject(jsonStrincidents0); + JSONObject jsonObj = new JSONObject(jsonStringIdents0); JSONArray data = jsonObj.getJSONArray("pages"); int a=0; JSONObject o = data.getJSONObject(a); @@ -114,7 +114,7 @@ public class StatusService extends Service { return null; } else - Log.e(TAG, dateStored+"updated json(service)"+stateDate); + Log.e(TAG, stateDate+"updated json(service)"+dateStored); } return null; @@ -137,8 +137,8 @@ public class StatusService extends Service { String CHANNEL_ID = "3168654312"; String CHANNEL_NAME = "StateNotification"; HttpHandler sh = new HttpHandler(); - String jsonStrincidents0 = sh.makeServiceCall(incidenturl0); - JSONObject jsonObj = new JSONObject(jsonStrincidents0); + String jsonStringIdents0 = sh.makeServiceCall( incidentUrl0 ); + JSONObject jsonObj = new JSONObject(jsonStringIdents0); JSONArray data = jsonObj.getJSONArray("pages"); int a=0; JSONObject o = data.getJSONObject(a); diff --git a/app/src/main/java/org/disroot/disrootapp/ui/AboutActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/AboutActivity.java index 072429e..de2cd3c 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/AboutActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/AboutActivity.java @@ -1,6 +1,7 @@ package org.disroot.disrootapp.ui; +import android.annotation.SuppressLint; import android.content.Intent; import android.net.Uri; import android.os.Build; @@ -43,12 +44,7 @@ public class AboutActivity extends AppCompatActivity { Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - onBackPressed(); - } - }); + toolbar.setNavigationOnClickListener( v -> onBackPressed() ); // Create the adapter that will return a fragment for each of the three // primary sections of the activity. /* @@ -59,7 +55,7 @@ public class AboutActivity extends AppCompatActivity { may be best to switch to a {@link android.support.v4.app.FragmentStatePagerAdapter}. */ - SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); + SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter( getSupportFragmentManager() ); // Set up the ViewPager with the sections adapter. /* @@ -74,16 +70,11 @@ public class AboutActivity extends AppCompatActivity { tabLayout.addOnTabSelectedListener(new TabLayout.ViewPagerOnTabSelectedListener(mViewPager)); FloatingActionButton fab = findViewById(R.id.fab); - fab.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Uri uri = Uri.parse(Constants.URL_SUPPORT); - Intent support = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(support); - // Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) - // .setAction("Action", null).show(); - } - }); + fab.setOnClickListener( view -> { + Uri uri = Uri.parse(Constants.URL_SUPPORT); + Intent support = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(support); + } ); } @@ -137,6 +128,7 @@ public class AboutActivity extends AppCompatActivity { return fragment; } + @SuppressLint("SetTextI18n") @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -151,67 +143,49 @@ public class AboutActivity extends AppCompatActivity { final Button ContributeBtn = rootView.findViewById(R.id.ContributeBtn);//ContributeBtn - ContributeBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_SOURCE); - Intent code = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(code); - } - }); + ContributeBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_SOURCE); + Intent code = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(code); + } ); final Button TranslateBtn = rootView.findViewById(R.id.TranslateBtn);//TranslateBtn - TranslateBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_TRANSLATE); - Intent translate = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(translate); - } - }); + TranslateBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_TRANSLATE); + Intent translate = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(translate); + } ); final Button FeedbackBtn1;//FeedbackBtn1 FeedbackBtn1 = rootView.findViewById(R.id.FeedbackBtn1); - FeedbackBtn1.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_BUGS); - Intent feedback1 = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(feedback1); - } - }); + FeedbackBtn1.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_BUGS); + Intent feedback1 = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(feedback1); + } ); final Button FeedbackBtn2 = rootView.findViewById(R.id.FeedbackBtn2);//FeedbackBtn2 - FeedbackBtn2.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_XMPP); - Intent feedback2 = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(feedback2); - } - }); + FeedbackBtn2.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_XMPP); + Intent feedback2 = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(feedback2); + } ); break; case 2: rootView = inflater.inflate(R.layout.fragment_about_about, container, false); final ImageButton fDroidBtn = rootView.findViewById(R.id.fDroidBtn);//fDroidBtn - fDroidBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_FDROID); - Intent fDroid = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(fDroid); - } - }); + fDroidBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_FDROID); + Intent fDroid = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(fDroid); + } ); final ImageButton homeBtn;//DisrootBtn homeBtn = rootView.findViewById(R.id.homeBtn); - homeBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_DISROOT); - Intent home = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(home); - } - }); + homeBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_DISROOT); + Intent home = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(home); + } ); final TextView PackageName= rootView.findViewById(R.id.PackageName); PackageName.setText(getString( R.string.id ) + " "+ APPLICATION_ID); @@ -229,13 +203,13 @@ public class AboutActivity extends AppCompatActivity { rootView = inflater.inflate(R.layout.fragment_about_license, container, false); //Contributors //Admins - final TextView contr_text; - contr_text = rootView.findViewById(R.id.admins_text); - contr_text.setMovementMethod( LinkMovementMethod.getInstance()); + final TextView contributors_text; + contributors_text = rootView.findViewById(R.id.admins_text); + contributors_text.setMovementMethod( LinkMovementMethod.getInstance()); String admins=""; for(String admin: Contributors.admins) { admins+="• "+admin+"
"; - contr_text.setText( Html.fromHtml(admins)); + contributors_text.setText( Html.fromHtml(admins)); } //devs final TextView devs_text; @@ -268,34 +242,25 @@ public class AboutActivity extends AppCompatActivity { //Buttons final Button licenseBtn;//LicenseBtn licenseBtn = rootView.findViewById(R.id.license_button); - licenseBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_LICENSE); - Intent license = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(license); - } - }); + licenseBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_LICENSE); + Intent license = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(license); + } ); final TextView disrootBtn;//DisrootBtn disrootBtn = rootView.findViewById(R.id.disrootUrl); - disrootBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_DISROOT); - Intent disroot = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(disroot); - } - }); - final TextView dioBtn;//DiotBtn + disrootBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_DISROOT); + Intent disroot = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(disroot); + } ); + final TextView dioBtn;//DioBtn dioBtn = rootView.findViewById(R.id.dioBtn); - dioBtn.setOnClickListener(new View.OnClickListener() - { - public void onClick(View arg0) { - Uri uri = Uri.parse(Constants.URL_DIO); - Intent dio = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(dio); - } - }); + dioBtn.setOnClickListener( arg0 -> { + Uri uri = Uri.parse(Constants.URL_DIO); + Intent dio = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(dio); + } ); final TextView htmlToTextView = rootView.findViewById(R.id.ThirdParty);// textview links clickable htmlToTextView.setMovementMethod( LinkMovementMethod.getInstance());// textview links clickable break; @@ -308,7 +273,7 @@ public class AboutActivity extends AppCompatActivity { * A {@link FragmentPagerAdapter} that returns a fragment corresponding to * one of the sections/tabs/pages. */ - public class SectionsPagerAdapter extends FragmentPagerAdapter { + public static class SectionsPagerAdapter extends FragmentPagerAdapter { final FragmentManager fm; diff --git a/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java index e54befe..4274b71 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/MainActivity.java @@ -92,8 +92,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL WebChromeClient.FileChooserParams chooserParams; ValueCallback chooserPathUri; Button button; - private Button MailBtn,CloudBtn,ForumBtn,ChatBtn,PadBtn,CalcBtn,BinBtn,UploadBtn,SearxBtn,PollsBtn,BoardBtn,CallsBtn,NotesBtn,GitBtn,UserBtn,StateBtn,HowToBtn,AboutBtn;//all buttons - private String email,cloud,forum,etherpad,ethercalc,bin,upload,searx,polls,taiga,user,xmpp,notes,git,cryptpad; + private Button MailBtn,CloudBtn,ForumBtn,ChatBtn,PadBtn, CryptpadBtn,BinBtn,UploadBtn,SearxBtn,BoardBtn,CallsBtn,NotesBtn,GitBtn,UserBtn,StateBtn,HowToBtn,AboutBtn;//all buttons + private String email,cloud,forum,etherpad,bin,upload,searx,taiga,user,xmpp,notes,git,cryptpad; private CookieManager cookieManager; private WebView webView; private DisWebChromeClient disWebChromeClient; @@ -157,11 +157,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL BtnPreference = getSharedPreferences( "ForumBtn", Context.MODE_PRIVATE );//forum BtnPreference = getSharedPreferences( "ChatBtn", Context.MODE_PRIVATE );//chat BtnPreference = getSharedPreferences( "PadBtn", Context.MODE_PRIVATE );//pad - BtnPreference = getSharedPreferences( "CalcBtn", Context.MODE_PRIVATE );//calc + BtnPreference = getSharedPreferences( "CryptpadBtn", Context.MODE_PRIVATE );//cryptpad BtnPreference = getSharedPreferences( "BinBtn", Context.MODE_PRIVATE );//bin BtnPreference = getSharedPreferences( "UploadBtn", Context.MODE_PRIVATE );//upload BtnPreference = getSharedPreferences( "SearxBtn", Context.MODE_PRIVATE );//search - BtnPreference = getSharedPreferences( "PollsBtn", Context.MODE_PRIVATE );//polls BtnPreference = getSharedPreferences( "BoardBtn", Context.MODE_PRIVATE );//board BtnPreference = getSharedPreferences( "CallsBtn", Context.MODE_PRIVATE );//calls BtnPreference = getSharedPreferences( "NotesBtn", Context.MODE_PRIVATE );//notes @@ -239,11 +238,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ForumBtn = findViewById( R.id.ForumBtn ); ChatBtn = findViewById( R.id.ChatBtn ); PadBtn = findViewById( R.id.PadBtn ); - CalcBtn = findViewById( R.id.CalcBtn ); + CryptpadBtn = findViewById( R.id.CryptpadBtn ); BinBtn = findViewById( R.id.BinBtn ); UploadBtn = findViewById( R.id.UploadBtn ); SearxBtn = findViewById( R.id.SearxBtn ); - PollsBtn = findViewById( R.id.PollsBtn ); BoardBtn = findViewById( R.id.BoardBtn ); CallsBtn = findViewById( R.id.CallsBtn ); NotesBtn = findViewById( R.id.NotesBtn ); @@ -278,11 +276,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ForumBtn.setOnLongClickListener( this ); ChatBtn.setOnLongClickListener( this ); PadBtn.setOnLongClickListener( this ); - CalcBtn.setOnLongClickListener( this ); + CryptpadBtn.setOnLongClickListener( this ); BinBtn.setOnLongClickListener( this ); UploadBtn.setOnLongClickListener( this ); SearxBtn.setOnLongClickListener( this ); - PollsBtn.setOnLongClickListener( this ); BoardBtn.setOnLongClickListener( this ); CallsBtn.setOnLongClickListener( this ); NotesBtn.setOnLongClickListener( this ); @@ -299,11 +296,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ForumBtn.setOnClickListener( this ); ChatBtn.setOnClickListener( this ); PadBtn.setOnClickListener( this ); - CalcBtn.setOnClickListener( this ); + CryptpadBtn.setOnClickListener( this ); BinBtn.setOnClickListener( this ); UploadBtn.setOnClickListener( this ); SearxBtn.setOnClickListener( this ); - PollsBtn.setOnClickListener( this ); BoardBtn.setOnClickListener( this ); CallsBtn.setOnClickListener( this ); NotesBtn.setOnClickListener( this ); @@ -395,8 +391,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL } else startActivity(pad); break; - case R.id.CalcBtn: - webView.loadUrl(Constants.URL_DisApp_CALC); + case R.id.CryptpadBtn: + webView.loadUrl(Constants.URL_DisApp_CRYPTPAD ); hideDashboard(); break; case R.id.BinBtn: @@ -411,10 +407,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL webView.loadUrl(Constants.URL_DisApp_SEARX); hideDashboard(); break; - case R.id.PollsBtn: - webView.loadUrl(Constants.URL_DisApp_POLL); - hideDashboard(); - break; case R.id.BoardBtn: webView.loadUrl(Constants.URL_DisApp_BOARD); hideDashboard(); @@ -486,8 +478,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL case R.id.PadBtn: showPadInfo(); break; - case R.id.CalcBtn: - showCalcInfo(); + case R.id.CryptpadBtn: + showCryptpadInfo(); break; case R.id.BinBtn: showBinInfo(); @@ -498,9 +490,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL case R.id.SearxBtn: showSearxInfo(); break; - case R.id.PollsBtn: - showPollsInfo(); - break; case R.id.BoardBtn: showBoardInfo(); break; @@ -888,16 +877,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL builder.show(); } - private void showCalcInfo() { + private void showCryptpadInfo() { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setCancelable(false); - builder.setTitle(R.string.CalcTitle); - builder.setMessage(ethercalc +"\n\n"+ getString(R.string.CalcInfo)); + builder.setTitle(R.string.CryptpadTitle ); + builder.setMessage(cryptpad +"\n\n"+ getString(R.string.CryptpadInfo )); builder.setPositiveButton(R.string.global_ok, null); builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - webView.loadUrl(Constants.URL_DisApp_CALCHELP); + webView.loadUrl(Constants.URL_DisApp_CRYPTPADHELP ); hideDashboard(); } }); @@ -905,9 +894,9 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL @Override public void onClick(DialogInterface dialog, int which) { ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent()); - if (findViewById( R.id.CalcBtn).getParent()!=null){ - viewGroup.removeView(CalcBtn); - BtnPreference.edit().putBoolean( "CalcBtn", false ).apply(); + if (findViewById( R.id.CryptpadBtn ).getParent()!=null){ + viewGroup.removeView( CryptpadBtn ); + BtnPreference.edit().putBoolean( "CryptpadBtn", false ).apply(); return;} } }); @@ -993,32 +982,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL builder.show(); } - private void showPollsInfo() { - AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); - builder.setCancelable(false); - builder.setTitle(R.string.PollsTitle); - builder.setMessage(polls +"\n\n"+ getString(R.string.PollsInfo)); - builder.setPositiveButton(R.string.global_ok, null); - builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - webView.loadUrl(Constants.URL_DisApp_POLLHELP); - hideDashboard(); - } - }); - builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent()); - if (findViewById( R.id.PollsBtn).getParent()!=null){ - viewGroup.removeView(PollsBtn); - BtnPreference.edit().putBoolean( "PollsBtn", false ).apply(); - return;} - } - }); - builder.show(); - } - private void showBoardInfo() { AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); builder.setCancelable(false); @@ -2004,57 +1967,64 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL { HashMap hashmap= (HashMap) componentList.get(a); String hash = hashmap.get("name"); + String description = ""; + if (hashmap.get("description")!=null &&!hashmap.isEmpty()){//.has("description")&&!hasmap.isNull("description") + description = hashmap.get("description"); + } + else { + description ="No Description"; + } switch (hash) { case "Notes": - notes = hashmap.get("notes"); + notes = description; getNotes(notes); break; case "Mail Server": - email = hashmap.get("description"); + email = description; getEmail(email); break; case "Cloud": - cloud = hashmap.get("description"); + cloud = description; getCloud(cloud); break; case "Forum": - forum = hashmap.get("description"); + forum = description; getForum(forum); break; case "Pad": - etherpad = hashmap.get("description"); + etherpad = description; getEtherpad(etherpad); break; case "Bin": - bin = hashmap.get("description"); + bin = description; getBin(bin); break; case "Upload": - upload = hashmap.get("description"); + upload = description; getUpload(upload); break; case "Searx": - searx = hashmap.get("description"); + searx = description; getSearx(searx); break; case "Project board": - taiga = hashmap.get("description"); + taiga = description; getTaiga(taiga); break; case "User Password management": - user = hashmap.get("description"); + user = description; getUser(user); break; case "XMPP Chat server": - xmpp = hashmap.get("description"); + xmpp = description; getXmpp(xmpp); break; case "Git": - git = hashmap.get("description"); + git = description; getGit(git); break; case "Cryptpad": - cryptpad = hashmap.get("description"); + cryptpad = description; getCryptpad(cryptpad); break; } @@ -2074,9 +2044,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL private void getEtherpad(String string){ etherpad = string; } - private void getEthercalc(String string){ - ethercalc = string; - } private void getBin(String string){ bin = string; } @@ -2086,9 +2053,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL private void getSearx(String string){ searx = string; } - private void getPolls(String string){ - polls = string; - } private void getTaiga(String string){ taiga = string; } diff --git a/app/src/main/java/org/disroot/disrootapp/ui/SettingsActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/SettingsActivity.java index 17ea372..ae3f55f 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/SettingsActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/SettingsActivity.java @@ -10,7 +10,6 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.CheckBox; -import android.widget.CompoundButton; import org.disroot.disrootapp.R; @@ -44,24 +43,18 @@ public class SettingsActivity extends AppCompatActivity { Toolbar toolbar = findViewById( R.id.toolbar ); setSupportActionBar( toolbar ); toolbar.setNavigationIcon( R.drawable.ic_arrow_back ); - toolbar.setNavigationOnClickListener( new View.OnClickListener() { - @Override - public void onClick(View v) { - onBackPressed(); - } - } ); + toolbar.setNavigationOnClickListener( v -> onBackPressed() ); - ////buttons visiblility preference list + ////buttons visibility preference list BtnPreference = getSharedPreferences( "MailBtn", Context.MODE_PRIVATE );//mail BtnPreference = getSharedPreferences( "CloudBtn", Context.MODE_PRIVATE );//cloud BtnPreference = getSharedPreferences( "ForumBtn", Context.MODE_PRIVATE );//forum BtnPreference = getSharedPreferences( "ChatBtn", Context.MODE_PRIVATE );//chat BtnPreference = getSharedPreferences( "PadBtn", Context.MODE_PRIVATE );//pad - BtnPreference = getSharedPreferences( "CalcBtn", Context.MODE_PRIVATE );//calc + BtnPreference = getSharedPreferences( "CryptpadBtn", Context.MODE_PRIVATE );//Cryptpad BtnPreference = getSharedPreferences( "BinBtn", Context.MODE_PRIVATE );//bin BtnPreference = getSharedPreferences( "UploadBtn", Context.MODE_PRIVATE );//upload - BtnPreference = getSharedPreferences( "SearxBtn", Context.MODE_PRIVATE );//search - BtnPreference = getSharedPreferences( "PollsBtn", Context.MODE_PRIVATE );//polls + BtnPreference = getSharedPreferences( "SearxBtn", Context.MODE_PRIVATE );//searx BtnPreference = getSharedPreferences( "BoardBtn", Context.MODE_PRIVATE );//Board BtnPreference = getSharedPreferences( "CallsBtn", Context.MODE_PRIVATE );//calls BtnPreference = getSharedPreferences( "NotesBtn", Context.MODE_PRIVATE );//notes @@ -70,7 +63,7 @@ public class SettingsActivity extends AppCompatActivity { BtnPreference = getSharedPreferences( "HowToBtn", Context.MODE_PRIVATE );//howTo BtnPreference = getSharedPreferences( "AboutBtn", Context.MODE_PRIVATE );//about - //checkboxlist + //checkbox list checkPrefBox(); } @@ -83,11 +76,10 @@ public class SettingsActivity extends AppCompatActivity { final CheckBox checkForumBtn = iconSettings.findViewById( R.id.foumBtnPreference );//forum final CheckBox checkChatBtn = iconSettings.findViewById( R.id.chatBtnPreference );//chat final CheckBox checkPadBtn = iconSettings.findViewById( R.id.padBtnPreference );//pad - final CheckBox checkCalcBtn = iconSettings.findViewById( R.id.calcBtnPreference );//calc + final CheckBox checkCryptpadBtn = iconSettings.findViewById( R.id.cryptpadBtnPreference );//cryptpad final CheckBox checkBinBtn = iconSettings.findViewById( R.id.binBtnPreference );//bin final CheckBox checkUploadBtn = iconSettings.findViewById( R.id.uploadBtnPreference );//upload final CheckBox checkSearxBtn = iconSettings.findViewById( R.id.searxBtnPreference );//search - final CheckBox checkPollsBtn = iconSettings.findViewById( R.id.pollsBtnPreference );//polls final CheckBox checkBoardBtn = iconSettings.findViewById( R.id.boardBtnPreference );//board final CheckBox checkCallsBtn = iconSettings.findViewById( R.id.callsBtnPreference );//calls final CheckBox checkNotesBtn = iconSettings.findViewById( R.id.notesBtnPreference );//notes @@ -102,11 +94,10 @@ public class SettingsActivity extends AppCompatActivity { if (BtnPreference.getBoolean( "ForumBtn", true )) checkForumBtn.setChecked( true );//forum if (BtnPreference.getBoolean( "ChatBtn", true )) checkChatBtn.setChecked( true );//chat if (BtnPreference.getBoolean( "PadBtn", true )) checkPadBtn.setChecked( true );//pad - if (BtnPreference.getBoolean( "CalcBtn", true )) checkCalcBtn.setChecked( true );//calc + if (BtnPreference.getBoolean( "CryptpadBtn", true )) checkCryptpadBtn.setChecked( true );//cryptpad if (BtnPreference.getBoolean( "BinBtn", true )) checkBinBtn.setChecked( true );//bin if (BtnPreference.getBoolean( "UploadBtn", true )) checkUploadBtn.setChecked( true );//upload if (BtnPreference.getBoolean( "SearxBtn", true )) checkSearxBtn.setChecked( true );//search - if (BtnPreference.getBoolean( "PollsBtn", true )) checkPollsBtn.setChecked( true );//polls if (BtnPreference.getBoolean( "BoardBtn", true )) checkBoardBtn.setChecked( true );//board if (BtnPreference.getBoolean( "CallsBtn", true )) checkCallsBtn.setChecked( true );//calls if (BtnPreference.getBoolean( "NotesBtn", true )) checkNotesBtn.setChecked( true );//notes @@ -116,211 +107,151 @@ public class SettingsActivity extends AppCompatActivity { if (BtnPreference.getBoolean( "AboutBtn", true )) checkAboutBtn.setChecked( true );//about //Mail - checkMailBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkMailBtn.isChecked()) { - BtnPreference.edit().putBoolean( "MailBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "MailBtn", false ).apply(); - } + checkMailBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkMailBtn.isChecked()) { + BtnPreference.edit().putBoolean( "MailBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "MailBtn", false ).apply(); } } ); //Cloud - checkCloudBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkCloudBtn.isChecked()) { - BtnPreference.edit().putBoolean( "CloudBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "CloudBtn", false ).apply(); - } + checkCloudBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkCloudBtn.isChecked()) { + BtnPreference.edit().putBoolean( "CloudBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "CloudBtn", false ).apply(); } } ); //forum - checkForumBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkForumBtn.isChecked()) { - BtnPreference.edit().putBoolean( "ForumBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "ForumBtn", false ).apply(); - } + checkForumBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkForumBtn.isChecked()) { + BtnPreference.edit().putBoolean( "ForumBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "ForumBtn", false ).apply(); } } ); //chat - checkChatBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkChatBtn.isChecked()) { - BtnPreference.edit().putBoolean( "ChatBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "ChatBtn", false ).apply(); - } + checkChatBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkChatBtn.isChecked()) { + BtnPreference.edit().putBoolean( "ChatBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "ChatBtn", false ).apply(); } } ); //pad - checkPadBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkPadBtn.isChecked()) { - BtnPreference.edit().putBoolean( "PadBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "PadBtn", false ).apply(); - } + checkPadBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkPadBtn.isChecked()) { + BtnPreference.edit().putBoolean( "PadBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "PadBtn", false ).apply(); } } ); - //calc - checkCalcBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkCalcBtn.isChecked()) { - BtnPreference.edit().putBoolean( "CalcBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "CalcBtn", false ).apply(); - } + //cryptpad + checkCryptpadBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkCryptpadBtn.isChecked()) { + BtnPreference.edit().putBoolean( "CryptpadBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "CryptpadBtn", false ).apply(); } } ); //bin - checkBinBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkBinBtn.isChecked()) { - BtnPreference.edit().putBoolean( "BinBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "BinBtn", false ).apply(); - } + checkBinBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkBinBtn.isChecked()) { + BtnPreference.edit().putBoolean( "BinBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "BinBtn", false ).apply(); } } ); //upload - checkUploadBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkUploadBtn.isChecked()) { - BtnPreference.edit().putBoolean( "UploadBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "UploadBtn", false ).apply(); - } + checkUploadBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkUploadBtn.isChecked()) { + BtnPreference.edit().putBoolean( "UploadBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "UploadBtn", false ).apply(); } } ); //search - checkSearxBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkSearxBtn.isChecked()) { - BtnPreference.edit().putBoolean( "SearxBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "SearxBtn", false ).apply(); - } - } - } ); - - //polls - checkPollsBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkPollsBtn.isChecked()) { - BtnPreference.edit().putBoolean( "PollsBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "PollsBtn", false ).apply(); - } + checkSearxBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkSearxBtn.isChecked()) { + BtnPreference.edit().putBoolean( "SearxBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "SearxBtn", false ).apply(); } } ); //board - checkBoardBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkBoardBtn.isChecked()) { - BtnPreference.edit().putBoolean( "BoardBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "BoardBtn", false ).apply(); - } + checkBoardBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkBoardBtn.isChecked()) { + BtnPreference.edit().putBoolean( "BoardBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "BoardBtn", false ).apply(); } } ); //board - checkCallsBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkCallsBtn.isChecked()) { - BtnPreference.edit().putBoolean( "CallsBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "CallsBtn", false ).apply(); - } + checkCallsBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkCallsBtn.isChecked()) { + BtnPreference.edit().putBoolean( "CallsBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "CallsBtn", false ).apply(); } } ); //notes - checkNotesBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkNotesBtn.isChecked()) { - BtnPreference.edit().putBoolean( "NotesBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "NotesBtn", false ).apply(); - } + checkNotesBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkNotesBtn.isChecked()) { + BtnPreference.edit().putBoolean( "NotesBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "NotesBtn", false ).apply(); } } ); //git - checkGitBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkGitBtn.isChecked()) { - BtnPreference.edit().putBoolean( "GitBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "GitBtn", false ).apply(); - } + checkGitBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkGitBtn.isChecked()) { + BtnPreference.edit().putBoolean( "GitBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "GitBtn", false ).apply(); } } ); //user - checkUserBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkUserBtn.isChecked()) { - BtnPreference.edit().putBoolean( "UserBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "UserBtn", false ).apply(); - } + checkUserBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkUserBtn.isChecked()) { + BtnPreference.edit().putBoolean( "UserBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "UserBtn", false ).apply(); } } ); //howTo - checkHowToBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkHowToBtn.isChecked()) { - BtnPreference.edit().putBoolean( "HowToBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "HowToBtn", false ).apply(); - } + checkHowToBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkHowToBtn.isChecked()) { + BtnPreference.edit().putBoolean( "HowToBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "HowToBtn", false ).apply(); } } ); //about - checkAboutBtn.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton view, boolean isChecked) { - if (checkAboutBtn.isChecked()) { - BtnPreference.edit().putBoolean( "AboutBtn", true ).apply(); - } else { - BtnPreference.edit().putBoolean( "AboutBtn", false ).apply(); - } + checkAboutBtn.setOnCheckedChangeListener( (view, isChecked) -> { + if (checkAboutBtn.isChecked()) { + BtnPreference.edit().putBoolean( "AboutBtn", true ).apply(); + } else { + BtnPreference.edit().putBoolean( "AboutBtn", false ).apply(); } } ); } - @Override //make sure changes are applyed when going back + @Override //make sure changes are applied when going back public void onBackPressed() { Intent goHome = new Intent( SettingsActivity.this, MainActivity.class ); SettingsActivity.this.startActivity( goHome ); diff --git a/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java index a589f09..3008dee 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/StateActivity.java @@ -33,14 +33,13 @@ public class StateActivity extends AppCompatActivity { Button button; - private String TAG = StateActivity.class.getSimpleName(); + private final String TAG = StateActivity.class.getSimpleName(); private ProgressDialog pDialog; private ListView lv; // URL to get data JSON static String url = "https://status.disroot.org/index.json"; - //static String url1 = "https://state.disroot.org/api/v1/components?sort=status&page=2"; ArrayList> stateList; @@ -52,22 +51,13 @@ public class StateActivity extends AppCompatActivity { Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - onBackPressed(); - } - }); - + toolbar.setNavigationOnClickListener( v -> onBackPressed() ); button = findViewById(R.id.StateMessageBtn);//StateMessageBtn - button.setOnClickListener(new View.OnClickListener() { - public void onClick(View arg0) { - Intent goState = new Intent(StateActivity.this, StateMessagesActivity.class); - StateActivity.this.startActivity(goState); - } - - }); + button.setOnClickListener( arg0 -> { + Intent goState = new Intent(StateActivity.this, StateMessagesActivity.class); + StateActivity.this.startActivity(goState); + } ); stateList = new ArrayList<>(); @@ -124,7 +114,6 @@ public class StateActivity extends AppCompatActivity { // Making a request to url and getting response String jsonStr0 = sh.makeServiceCall(url); - //String jsonStr1 = sh.makeServiceCall(url1); Log.e(TAG, "Response from url: " + jsonStr0); @@ -162,70 +151,18 @@ public class StateActivity extends AppCompatActivity { } } catch (final JSONException e) { Log.e(TAG, "Json parsing error: " + e.getMessage()); - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(getApplicationContext(), - "Json parsing error: " + e.getMessage(), - Toast.LENGTH_LONG) - .show(); - } - }); + runOnUiThread( () -> Toast.makeText(getApplicationContext(), + "Json parsing error: " + e.getMessage(), + Toast.LENGTH_LONG) + .show() ); } - }/*if (jsonStr1 != null) {//next page - try { - JSONObject jsonObj = new JSONObject(jsonStr1); - - // Getting JSON Array node - JSONArray data = jsonObj.getJSONArray("data"); - - // looping through All data - for (int i = 0; i < data.length(); i++) { - JSONObject c = data.getJSONObject(i); - - String id = c.getString("id"); - String name = c.getString("name"); - String description = c.getString("description"); - String updated_at = c.getString("updated_at"); - String lastUpdated = "Last updated: " + updated_at; - String status_name = c.getString("status_name"); - - // tmp hash map for single service - HashMap service = new HashMap<>(); - - // adding each child node to HashMap key => value - service.put("id", id); - service.put("name", name); - service.put("description", description); - service.put("updated_at", lastUpdated); - service.put("status_name", status_name); - - // adding service to service list - stateList.add(service); - } - } catch (final JSONException e) { - Log.e(TAG, "Json parsing error: " + e.getMessage()); - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(getApplicationContext(), - "Json parsing error: " + e.getMessage(), - Toast.LENGTH_LONG) - .show(); - } - }); - } - }*/else { + } + else { Log.e(TAG, "Couldn't get json from server."); - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(getApplicationContext(), - "Couldn't get json from server. Is your internet connection ok?", - Toast.LENGTH_LONG) - .show(); - } - }); + runOnUiThread( () -> Toast.makeText(getApplicationContext(), + "Couldn't get json from server. Is your internet connection ok?", + Toast.LENGTH_LONG) + .show() ); } return null; } @@ -239,18 +176,18 @@ public class StateActivity extends AppCompatActivity { //Updating parsed JSON data into ListView ListAdapter adapter = new SimpleAdapter( - StateActivity.this, stateList, R.layout.list_item, + StateActivity.this, stateList, R.layout.list_services, new String[]{"name", "description", "category","status"}, - new int[]{R.id.name,R.id.description,R.id.lastMod, R.id.status_name}) + new int[]{R.id.name,R.id.description,R.id.category, R.id.status}) - //Change Color based on Status + //Change Color based on Status { @Override public View getView(int position, View convertView, ViewGroup parent) { View v = super.getView(position, convertView, parent); //Status - TextView status = v.findViewById(R.id.status_name); + TextView status = v.findViewById(R.id.status); String statusValue = status.getText().toString(); switch (statusValue) { case "ok": diff --git a/app/src/main/java/org/disroot/disrootapp/ui/StateMessagesActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/StateMessagesActivity.java index 232aac1..9b3f941 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/StateMessagesActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/StateMessagesActivity.java @@ -33,12 +33,12 @@ import java.util.HashMap; public class StateMessagesActivity extends AppCompatActivity { Button button; - private String TAG = StateMessagesActivity.class.getSimpleName(); + private final String TAG = StateMessagesActivity.class.getSimpleName(); private ProgressDialog pDialog; private ListView lv; // URL to get data JSON - static String incidenturl0 ="https://status.disroot.org/issues/index.json"; + static String incidentUrl0 ="https://status.disroot.org/issues/index.json"; ArrayList> messageList; ArrayList> getDate; @@ -51,22 +51,13 @@ public class StateMessagesActivity extends AppCompatActivity { Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(R.drawable.ic_arrow_back); - toolbar.setNavigationOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - onBackPressed(); - } - }); - + toolbar.setNavigationOnClickListener( v -> onBackPressed() ); button = findViewById(R.id.StateBtn);//StateBtn - button.setOnClickListener(new View.OnClickListener() { - public void onClick(View arg0) { - Intent goState = new Intent(StateMessagesActivity.this, StateActivity.class); - StateMessagesActivity.this.startActivity(goState); - } - - }); + button.setOnClickListener( arg0 -> { + Intent goState = new Intent(StateMessagesActivity.this, StateActivity.class); + StateMessagesActivity.this.startActivity(goState); + } ); messageList = new ArrayList<>(); getDate = new ArrayList<>(); @@ -117,13 +108,13 @@ public class StateMessagesActivity extends AppCompatActivity { HttpHandler sh = new HttpHandler(); // Making a request to url and getting response - String jsonStrincidents0 = sh.makeServiceCall(incidenturl0); + String jsonStringIdents0 = sh.makeServiceCall( incidentUrl0 ); - Log.e(TAG, "Response from url: " + incidenturl0); + Log.e(TAG, "Response from url: " + incidentUrl0 ); - if (jsonStrincidents0 != null) {//Incidaetnts page + if (jsonStringIdents0 != null) {//Incidents page try { - JSONObject jsonObj = new JSONObject(jsonStrincidents0); + JSONObject jsonObj = new JSONObject( jsonStringIdents0 ); // Getting JSON Array node JSONArray data = jsonObj.getJSONArray("pages"); @@ -132,10 +123,9 @@ public class StateMessagesActivity extends AppCompatActivity { for (int i = 0; i < data.length(); i++) { JSONObject c = data.getJSONObject(i); - //String id = c.getString("id"); String title = c.getString("title"); String link = c.getString("permalink"); - Boolean resolved = c.getBoolean( "resolved" ); + boolean resolved = c.getBoolean( "resolved" ); String lastMod = c.getString("lastMod"); String lastUpdated = "Last Updated: " + lastMod + '"'; @@ -145,7 +135,7 @@ public class StateMessagesActivity extends AppCompatActivity { // adding each child node to HashMap key => value service.put("title", title); service.put("moreInfo", link); - service.put("resolved", resolved.toString()); + service.put("resolved", Boolean.toString( resolved ) ); service.put("lastMod", lastUpdated); // adding service to service list @@ -153,27 +143,17 @@ public class StateMessagesActivity extends AppCompatActivity { } } catch (final JSONException e) { Log.e(TAG, "Json parsing error: " + e.getMessage()); - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(getApplicationContext(), - "Json parsing error: " + e.getMessage(), - Toast.LENGTH_LONG) - .show(); - } - }); + runOnUiThread( () -> Toast.makeText(getApplicationContext(), + "Json parsing error: " + e.getMessage(), + Toast.LENGTH_LONG) + .show() ); } }else { Log.e(TAG, "Couldn't get json from server."); - runOnUiThread(new Runnable() { - @Override - public void run() { - Toast.makeText(getApplicationContext(), - "Couldn't get json from server. Is your internet connection ok?", - Toast.LENGTH_LONG) - .show(); - } - }); + runOnUiThread( () -> Toast.makeText(getApplicationContext(), + "Couldn't get json from server. Is your internet connection ok?", + Toast.LENGTH_LONG) + .show() ); } return null; } @@ -188,8 +168,8 @@ public class StateMessagesActivity extends AppCompatActivity { //Updating parsed JSON data into ListView ListAdapter adapter = new SimpleAdapter( StateMessagesActivity.this, messageList, - R.layout.list_item, new String[]{"title","moreInfo", "lastMod", "resolved", "status"}, new int[]{R.id.name, R.id.message, - R.id.lastMod, R.id.resolved, R.id.status}) + R.layout.list_service_messages, new String[]{"title","moreInfo", "lastMod", "resolved", "status"}, new int[]{R.id.name, R.id.description, + R.id.category, R.id.resolved, R.id.status}) { @@ -200,22 +180,17 @@ public class StateMessagesActivity extends AppCompatActivity { //Make links work - TextView link = v.findViewById( R.id.message ); + TextView link = v.findViewById( R.id.description ); String linkValue = link.getText().toString(); link.setText( R.string.more_info); - v.setOnClickListener(new View.OnClickListener() { - - public void onClick(View arg0) { - - Uri uri = Uri.parse( linkValue); - Intent statusLink = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(statusLink); - } - - }); + v.setOnClickListener( arg0 -> { + Uri uri = Uri.parse( linkValue); + Intent statusLink = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(statusLink); + } ); //Make Last updated translatable - TextView updated = v.findViewById(R.id.lastMod ); + TextView updated = v.findViewById(R.id.category ); String updatedValue = updated.getText().toString(); if (updatedValue.startsWith("Last Updated: ")){ updated.setText(updatedValue.replace("Last Updated: ",getText(R.string.LastUpdated))); @@ -224,18 +199,17 @@ public class StateMessagesActivity extends AppCompatActivity { TextView resolved = v.findViewById(R.id.resolved ); String resolvedValue = resolved.getText().toString(); //Human_status - TextView humanStatus = v.findViewById(R.id.status ); - String humanStatusValue = humanStatus.getText().toString(); - Log.e("status", "status: "+humanStatusValue); + TextView status = v.findViewById(R.id.status ); + Log.e("status", "status: "+resolvedValue); switch (resolvedValue) { case "true": - humanStatus.setTextColor(Color.GREEN); - humanStatus.setText(R.string.Fixed); + status.setTextColor(Color.GREEN); + status.setText(R.string.Fixed); resolved.setVisibility(View.GONE ); break; case "false": - humanStatus.setTextColor(Color.RED); - humanStatus.setText(R.string.down); + status.setTextColor(Color.RED); + status.setText(R.string.down); resolved.setVisibility(View.GONE ); break; } diff --git a/app/src/main/java/org/disroot/disrootapp/ui/WelcomeActivity.java b/app/src/main/java/org/disroot/disrootapp/ui/WelcomeActivity.java index c7a59b0..04cc4eb 100644 --- a/app/src/main/java/org/disroot/disrootapp/ui/WelcomeActivity.java +++ b/app/src/main/java/org/disroot/disrootapp/ui/WelcomeActivity.java @@ -4,7 +4,6 @@ import android.content.Intent; import android.net.Uri; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; -import android.view.View; import android.widget.ImageButton; import org.disroot.disrootapp.R; @@ -19,22 +18,16 @@ public class WelcomeActivity extends AppCompatActivity { super.onCreate(savedInstanceState); setContentView(R.layout.activity_welcome); imageButton = findViewById(R.id.homeBtn);//Home - imageButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View arg0) { - Intent goHome = new Intent(WelcomeActivity.this, MainActivity.class); - WelcomeActivity.this.startActivity(goHome); - } - - }); + imageButton.setOnClickListener( arg0 -> { + Intent goHome = new Intent(WelcomeActivity.this, MainActivity.class); + WelcomeActivity.this.startActivity(goHome); + } ); imageButton = findViewById(R.id.fDroidBtn);//Home - imageButton.setOnClickListener(new View.OnClickListener() { - public void onClick(View arg0) { - Uri uri = Uri.parse(String.valueOf(Constants.URL_FDROID)); - Intent fDroid = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); - startActivity(fDroid); - } - - }); + imageButton.setOnClickListener( arg0 -> { + Uri uri = Uri.parse( Constants.URL_FDROID ); + Intent fDroid = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri))); + startActivity(fDroid); + } ); } } diff --git a/app/src/main/java/org/disroot/disrootapp/utils/Constants.java b/app/src/main/java/org/disroot/disrootapp/utils/Constants.java index f7d1708..16bfd2b 100644 --- a/app/src/main/java/org/disroot/disrootapp/utils/Constants.java +++ b/app/src/main/java/org/disroot/disrootapp/utils/Constants.java @@ -10,14 +10,11 @@ public class Constants { public static final long SPLASH_SCREEN_DURATION = 3000; public static final long SPLASH_SCREEN_INTERVAL = 1000; - - public static final String title_activity_state = "StateActivity"; public static final String URL_DisApp_FORUM = "https://forum.disroot.org/"; - public static final String URL_DisApp_CALC = "https://calc.disroot.org"; + public static final String URL_DisApp_CRYPTPAD = "https://cryptpad.disroot.org/"; public static final String URL_DisApp_BIN = "https://bin.disroot.org"; public static final String URL_DisApp_UPLOAD = "https://upload.disroot.org"; public static final String URL_DisApp_SEARX = "https://search.disroot.org"; - public static final String URL_DisApp_POLL = "https://poll.disroot.org"; public static final String URL_DisApp_BOARD = "https://board.disroot.org"; public static final String URL_DisApp_USER = "https://user.disroot.org"; public static final String URL_DisApp_HOWTO = "https://howto.disroot.org"; @@ -41,13 +38,11 @@ public class Constants { public static final String URL_XMPP = "xmpp:disroot@chat.disroot.org?join"; public static final String URL_SUPPORT = "mailto:support@disroot.org"; public static final String URL_DisApp_CLOUDHELP = "https://howto.disroot.org/en/tutorials/cloud/clients/mobile/android"; - public static final String URL_DisApp_DIAHELP = "https://disroot.org/services/diaspora"; public static final String URL_DisApp_FORUMHELP = "https://howto.disroot.org/en/tutorials/forum"; public static final String URL_DisApp_PADHELP = "https://howto.disroot.org/en/tutorials/office/pads/padland"; - public static final String URL_DisApp_CALCHELP = "https://howto.disroot.org/en/tutorials/office/pads/ethercalc"; + public static final String URL_DisApp_CRYPTPADHELP = "https://howto.disroot.org/it/tutorials/office/cryptpad"; public static final String URL_DisApp_BINHELP = "https://howto.disroot.org/en/tutorials/office/bin"; public static final String URL_DisApp_UPLOADHELP = "https://howto.disroot.org/en/tutorials/office/lufi"; - public static final String URL_DisApp_POLLHELP = "https://howto.disroot.org/en/tutorials/office/polls"; public static final String URL_DisApp_BOARDHELP = "https://howto.disroot.org/en/tutorials/project_board"; public static final String URL_DisApp_NOTESHELP = "https://howto.disroot.org/en/tutorials/cloud/clients/mobile/android/using-notes"; public static final String URL_DisApp_CALLSHELP = "https://disroot.org/en/services/calls"; @@ -64,7 +59,7 @@ public class Constants { public static final String CallsApp = "org.jitsi.meet"; public static final String GitApp = "org.mian.gitnex"; - public static final int[] buttonIDs = new int[] {R.id.MailBtn, R.id.CloudBtn, R.id.ForumBtn,R.id.ChatBtn,R.id.PadBtn,R.id.CalcBtn,R.id.BinBtn,R.id.UploadBtn,R.id.SearxBtn,R.id.PollsBtn,R.id.BoardBtn,R.id.CallsBtn,R.id.NotesBtn,R.id.GitBtn,R.id.UserBtn,R.id.StateBtn,R.id.HowToBtn,R.id.AboutBtn}; + public static final int[] buttonIDs = new int[] {R.id.MailBtn, R.id.CloudBtn, R.id.ForumBtn,R.id.ChatBtn,R.id.PadBtn,R.id.CryptpadBtn,R.id.BinBtn,R.id.UploadBtn,R.id.SearxBtn,R.id.BoardBtn,R.id.CallsBtn,R.id.NotesBtn,R.id.GitBtn,R.id.UserBtn,R.id.StateBtn,R.id.HowToBtn,R.id.AboutBtn}; public static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;//file upload diff --git a/app/src/main/res/drawable/ic_calc.xml b/app/src/main/res/drawable/ic_cryptpad.xml similarity index 100% rename from app/src/main/res/drawable/ic_calc.xml rename to app/src/main/res/drawable/ic_cryptpad.xml diff --git a/app/src/main/res/drawable/ic_poll.xml b/app/src/main/res/drawable/ic_poll.xml deleted file mode 100644 index 3281fc4..0000000 --- a/app/src/main/res/drawable/ic_poll.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 4f4e89e..87e23bd 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -137,12 +137,12 @@ app:fontFamily="@font/open_sans_regular" />