Added Cryptpad

Removed Calc
Removed Polls
Refractor
Improved ui state
master
massi 2022-10-29 02:01:02 +02:00
parent f01c6cb893
commit c4e8167efc
35 changed files with 430 additions and 677 deletions

View File

@ -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

View File

@ -64,14 +64,11 @@
android:host="forum.disroot.org"
android:scheme="https" />
<data
android:host="calc.disroot.org"
android:host="cryptpad.disroot.org"
android:scheme="https" />
<data
android:host="bin.disroot.org"
android:scheme="https" />
<data
android:host="poll.disroot.org"
android:scheme="https" />
<data
android:host="upload.disroot.org"
android:scheme="https" />

View File

@ -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) {

View File

@ -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<HashMap<String, String>> messageList;
ArrayList<HashMap<String, String>> 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);

View File

@ -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+="&bull; "+admin+"</a><br>";
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;

View File

@ -92,8 +92,8 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
WebChromeClient.FileChooserParams chooserParams;
ValueCallback<Uri[]> 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<String, String> hashmap= (HashMap<String, String>) 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;
}

View File

@ -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 );

View File

@ -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<HashMap<String, String>> 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<String, String> 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":

View File

@ -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<HashMap<String, String>> messageList;
ArrayList<HashMap<String, String>> 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