2018-09-02 19:00:45 +02:00
|
|
|
package org.disroot.disrootapp.ui;
|
|
|
|
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.Manifest;
|
|
|
|
import android.annotation.TargetApi;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.app.AlertDialog;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.app.DownloadManager;
|
2019-05-26 01:01:54 +02:00
|
|
|
import android.content.Context;
|
2018-09-09 18:52:57 +02:00
|
|
|
import android.content.DialogInterface;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.content.Intent;
|
2018-09-09 17:41:03 +02:00
|
|
|
import android.content.SharedPreferences;
|
2019-05-26 01:01:54 +02:00
|
|
|
import android.content.pm.PackageInfo;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.graphics.Bitmap;
|
2018-09-15 02:03:38 +02:00
|
|
|
import android.graphics.Color;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.net.Uri;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.os.Build;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.os.Bundle;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.os.Environment;
|
2018-09-14 09:44:30 +02:00
|
|
|
import android.os.Handler;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.os.Parcelable;
|
2019-05-26 01:01:54 +02:00
|
|
|
import android.os.PowerManager;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.provider.MediaStore;
|
2019-05-26 01:01:54 +02:00
|
|
|
import android.provider.Settings;
|
2018-09-15 02:03:38 +02:00
|
|
|
import android.support.annotation.NonNull;
|
2018-09-13 21:15:45 +02:00
|
|
|
import android.support.annotation.RequiresApi;
|
2019-02-18 20:25:22 +01:00
|
|
|
import android.support.design.widget.Snackbar;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.support.v4.app.ActivityCompat;
|
2019-02-18 20:25:22 +01:00
|
|
|
import android.support.v4.app.FragmentManager;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.support.v4.content.ContextCompat;
|
2018-12-30 12:24:59 +01:00
|
|
|
import android.support.v4.widget.SwipeRefreshLayout;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.support.v7.app.AppCompatActivity;
|
2018-11-06 00:09:41 +01:00
|
|
|
import android.support.v7.app.AppCompatDelegate;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.support.v7.widget.Toolbar;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.view.KeyEvent;
|
2018-09-16 22:00:20 +02:00
|
|
|
import android.view.LayoutInflater;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
2018-09-16 22:00:20 +02:00
|
|
|
import android.view.ViewGroup;
|
2018-09-08 03:39:01 +02:00
|
|
|
import android.view.animation.TranslateAnimation;
|
2018-11-06 00:09:41 +01:00
|
|
|
import android.webkit.CookieManager;
|
|
|
|
import android.webkit.CookieSyncManager;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.webkit.DownloadListener;
|
|
|
|
import android.webkit.GeolocationPermissions;
|
|
|
|
import android.webkit.URLUtil;
|
|
|
|
import android.webkit.ValueCallback;
|
|
|
|
import android.webkit.WebChromeClient;
|
2018-11-06 00:09:41 +01:00
|
|
|
import android.webkit.WebSettings;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.webkit.WebView;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.webkit.WebViewClient;
|
2018-09-07 20:22:31 +02:00
|
|
|
import android.widget.Button;
|
2018-09-20 16:44:19 +02:00
|
|
|
import android.widget.CheckBox;
|
|
|
|
import android.widget.CompoundButton;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.widget.FrameLayout;
|
2018-09-15 02:03:38 +02:00
|
|
|
import android.widget.ImageButton;
|
2018-09-13 14:38:45 +02:00
|
|
|
import android.widget.ProgressBar;
|
2018-09-08 03:39:01 +02:00
|
|
|
import android.widget.ScrollView;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
import org.disroot.disrootapp.R;
|
2019-05-22 16:45:27 +02:00
|
|
|
import org.disroot.disrootapp.StatusService;
|
2018-09-02 19:00:45 +02:00
|
|
|
import org.disroot.disrootapp.utils.Constants;
|
|
|
|
import org.disroot.disrootapp.webviews.DisWebChromeClient;
|
|
|
|
|
2018-09-13 14:38:45 +02:00
|
|
|
import java.io.File;
|
|
|
|
import java.io.IOException;
|
2018-09-02 19:00:45 +02:00
|
|
|
import java.lang.reflect.Method;
|
2018-09-13 14:38:45 +02:00
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2018-09-13 16:58:36 +02:00
|
|
|
import de.cketti.library.changelog.ChangeLog;
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
@SuppressWarnings("ALL")
|
2018-09-02 19:00:45 +02:00
|
|
|
public class MainActivity extends AppCompatActivity implements View.OnLongClickListener {
|
|
|
|
|
|
|
|
private static final String TAG = MainActivity.class.getSimpleName();
|
|
|
|
private WebView webView;
|
|
|
|
private DisWebChromeClient disWebChromeClient;
|
2018-09-07 20:22:31 +02:00
|
|
|
Button button;
|
2018-09-09 17:41:03 +02:00
|
|
|
SharedPreferences firstStart = null;//first start
|
2018-09-20 16:44:19 +02:00
|
|
|
SharedPreferences check = null;
|
2018-09-13 14:38:45 +02:00
|
|
|
private static final int INPUT_FILE_REQUEST_CODE = 1;//file upload
|
|
|
|
private static final int FILECHOOSER_RESULTCODE = 1;
|
|
|
|
String loadUrl;
|
|
|
|
private ValueCallback<Uri> mUploadMessage;
|
|
|
|
private Uri mCapturedImageURI = null;
|
|
|
|
private ValueCallback<Uri[]> mFilePathCallback;
|
|
|
|
private String mCameraPhotoPath;
|
|
|
|
ValueCallback<Uri[]> chooserPathUri;
|
|
|
|
private ProgressBar progressBar;
|
2018-09-14 09:44:30 +02:00
|
|
|
private int progressStatus = 0;
|
|
|
|
private Handler handler = new Handler();
|
2019-02-18 20:25:22 +01:00
|
|
|
private Snackbar snackbarExitApp;
|
|
|
|
private FragmentManager fm;
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
public static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;
|
|
|
|
|
|
|
|
WebView chooserWV;
|
|
|
|
WebChromeClient.FileChooserParams chooserParams;
|
|
|
|
|
|
|
|
public static final String CONTENT_HASHTAG = "content://org.disroot.disrootapp.ui.mainactivity/";
|
2018-09-09 17:41:03 +02:00
|
|
|
|
2018-11-06 00:09:41 +01:00
|
|
|
private CookieManager cookieManager;
|
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_main);
|
2018-09-15 02:03:38 +02:00
|
|
|
FrameLayout frameLayoutContainer = findViewById(R.id.framelayout_container);
|
|
|
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
2018-09-14 15:42:30 +02:00
|
|
|
setSupportActionBar(toolbar);
|
2018-09-14 09:44:30 +02:00
|
|
|
//ViewGroup viewLoading = (ViewGroup) findViewById(R.id.linearlayout_view_loading_container);
|
2018-09-13 14:38:45 +02:00
|
|
|
setupWebView(savedInstanceState, frameLayoutContainer);
|
2018-09-09 17:41:03 +02:00
|
|
|
firstStart = getSharedPreferences("org.disroot.disrootap", MODE_PRIVATE);//fisrt start
|
2018-09-20 16:44:19 +02:00
|
|
|
check = getSharedPreferences("org.disroot.disrootapp", MODE_PRIVATE);
|
2018-09-02 19:00:45 +02:00
|
|
|
// enables the activity icon as a 'home' button. required if "android:targetSdkVersion" > 14
|
|
|
|
//getActionBar().setHomeButtonEnabled(true);
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-14 09:44:30 +02:00
|
|
|
//progressbarLoading
|
2018-09-15 02:03:38 +02:00
|
|
|
progressBar = findViewById(R.id.progressbarLoading);
|
2018-09-14 09:44:30 +02:00
|
|
|
// Start long running operation in a background thread
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
while (progressStatus < 100) {
|
|
|
|
progressStatus += 1;
|
|
|
|
// Update the progress bar and display the
|
|
|
|
//current value in the text view
|
|
|
|
handler.post(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
progressBar.setProgress(progressStatus);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
try {
|
|
|
|
// Sleep for 200 milliseconds.
|
|
|
|
Thread.sleep(200);
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).start();
|
2018-09-13 16:58:36 +02:00
|
|
|
|
|
|
|
//ckCangelog library
|
|
|
|
ChangeLog cl = new ChangeLog(this);
|
|
|
|
if (cl.isFirstRun()) {
|
|
|
|
cl.getLogDialog().show();
|
|
|
|
}
|
2018-09-30 00:08:57 +02:00
|
|
|
|
|
|
|
//set booleans for checking Chat preference
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
check.edit().putBoolean("checkConv",false).apply();
|
|
|
|
check.edit().putBoolean("checkPix",false).apply();
|
|
|
|
}
|
|
|
|
|
2018-12-30 12:24:59 +01:00
|
|
|
//pull to refresh
|
|
|
|
final SwipeRefreshLayout swipe = (SwipeRefreshLayout)findViewById(R.id.swipe);
|
|
|
|
swipe.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener()
|
|
|
|
{
|
|
|
|
@Override
|
|
|
|
public void onRefresh(){
|
|
|
|
swipe.setRefreshing( false );
|
|
|
|
String url = webView.getUrl();
|
|
|
|
webView.loadUrl(url);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-02-18 20:25:22 +01:00
|
|
|
//Setup snackbar
|
|
|
|
snackbarExitApp = Snackbar
|
|
|
|
.make(findViewById(R.id.framelayout_container), R.string.do_you_want_to_exit, Snackbar.LENGTH_LONG)
|
2019-02-19 19:03:37 +01:00
|
|
|
.setActionTextColor( Color.LTGRAY )
|
2019-02-18 20:25:22 +01:00
|
|
|
.setAction(android.R.string.yes, new View.OnClickListener() {
|
|
|
|
public void onClick(View view) {
|
|
|
|
finish();
|
|
|
|
moveTaskToBack(true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-07 20:22:31 +02:00
|
|
|
//Set buttons
|
|
|
|
// Locate the button in activity_main.xml
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.MailBtn);//MailBtn
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showMailInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-11-18 13:01:02 +01:00
|
|
|
//first time tap check
|
2018-09-13 14:38:45 +02:00
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
2018-11-18 13:01:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
String k9 = "com.fsck.k9";
|
|
|
|
Intent mail = getPackageManager().getLaunchIntentForPackage(k9);
|
|
|
|
if(mail == null) {
|
|
|
|
showMailDialog();
|
|
|
|
return;
|
2018-09-07 20:22:31 +02:00
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
else startActivity(mail);
|
2018-09-07 20:22:31 +02:00
|
|
|
}
|
2018-09-30 21:32:56 +02:00
|
|
|
|
2018-09-07 20:22:31 +02:00
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
|
2018-09-30 21:32:56 +02:00
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.CloudBtn);//CloudBtn
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showCloudInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-11-18 13:01:02 +01:00
|
|
|
//first time tap check
|
2018-09-13 14:38:45 +02:00
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
2018-11-18 13:01:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
String nc = "com.nextcloud.client";
|
|
|
|
Intent cloud = getPackageManager().getLaunchIntentForPackage(nc);
|
|
|
|
if(cloud == null) {
|
|
|
|
showCloudDialog();
|
|
|
|
return;
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
else startActivity(cloud);
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.DiasporaBtn);//DiasporaBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showDiaInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-11-18 13:01:02 +01:00
|
|
|
//first time tap check
|
2018-09-13 14:38:45 +02:00
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
2018-11-18 13:01:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
String Diaspora = "com.github.dfa.diaspora_android";
|
|
|
|
Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora);
|
|
|
|
if(pod == null) {
|
|
|
|
showDiaDialog();
|
|
|
|
return;
|
2018-09-07 20:22:31 +02:00
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
else startActivity(pod);
|
2018-09-07 20:22:31 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.ForumBtn);//ForumBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showForumInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_FORUM);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.ChatBtn);//ChatBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showChatInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
String Conversations = "eu.siacs.conversations";
|
2018-09-09 20:16:07 +02:00
|
|
|
Intent xmpp1 = getPackageManager().getLaunchIntentForPackage(Conversations);
|
|
|
|
String PixArt = "de.pixart.messenger";
|
|
|
|
Intent xmpp2 = getPackageManager().getLaunchIntentForPackage(PixArt);
|
2018-09-22 12:14:39 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
2018-09-09 20:16:07 +02:00
|
|
|
if((xmpp1 == null)&&(xmpp2 == null)) {
|
2018-11-18 13:01:02 +01:00
|
|
|
showChatDialog();
|
|
|
|
return;
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
2018-09-15 02:03:38 +02:00
|
|
|
/* if((xmpp1 == null)&&(xmpp2 != null)) { */
|
2018-09-20 16:44:19 +02:00
|
|
|
if((xmpp1 == null)&&(xmpp2 != null)) {//if(xmpp1 == null) {
|
2018-09-09 20:16:07 +02:00
|
|
|
startActivity(xmpp2);
|
2018-12-09 18:42:42 +01:00
|
|
|
return;
|
2018-09-09 20:16:07 +02:00
|
|
|
}
|
2018-09-20 16:44:19 +02:00
|
|
|
//need to change to give user choise || check.getBoolean("checkPix",false)
|
2018-09-09 20:16:07 +02:00
|
|
|
if((xmpp1 != null)&&(xmpp2 != null)) {
|
2018-09-22 12:14:39 +02:00
|
|
|
if(check.getBoolean("checkConv", Boolean.parseBoolean(null))||check.getBoolean("checkConv", false)) {
|
2018-09-20 16:44:19 +02:00
|
|
|
startActivity(xmpp1);
|
|
|
|
return;
|
|
|
|
}
|
2018-09-22 12:14:39 +02:00
|
|
|
if(check.getBoolean("checkPix", Boolean.parseBoolean(null))||check.getBoolean("checkPix", false)) {
|
2018-09-20 16:44:19 +02:00
|
|
|
startActivity(xmpp2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
showChoose();
|
|
|
|
return;
|
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
else
|
2018-09-09 20:16:07 +02:00
|
|
|
startActivity(xmpp1);
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.PadBtn);//PadBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showPadInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
2018-11-18 13:01:02 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
String Padland = "com.mikifus.padland";
|
|
|
|
Intent pad = getPackageManager().getLaunchIntentForPackage(Padland);
|
|
|
|
if(pad == null) {
|
|
|
|
showPAdDialog();
|
|
|
|
return;
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
else startActivity(pad);
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.CalcBtn);//CalcBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showCalcInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_CALC);
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.BinBtn);//BinBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showBinInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_BIN);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.UploadBtn);//UploadBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showUploadInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
2018-11-07 20:27:58 +01:00
|
|
|
else {
|
|
|
|
Uri uri = Uri.parse(Constants.URL_DisApp_UPLOAD);
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
//workaround for crashing app
|
|
|
|
// webView.loadUrl(Constants.URL_DisApp_UPLOAD);
|
|
|
|
// webView.setVisibility(View.VISIBLE);
|
|
|
|
// dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.SearxBtn);//SearxBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showSearxInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_SEARX);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.PollsBtn);//PollsBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showPollsInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_POLL);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.BoardBtn);//BoardBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showBoardInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_BOARD);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-12-18 21:00:58 +01:00
|
|
|
button = findViewById(R.id.NotesBtn);//NotesBtn
|
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showNotesInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
String NotesApp = "it.niedermann.owncloud.notes";
|
|
|
|
Intent notes = getPackageManager().getLaunchIntentForPackage(NotesApp);
|
|
|
|
if(notes == null) {
|
|
|
|
showNotesDialog();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else startActivity(notes);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.UserBtn);//UserBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showUserInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_USER);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.StateBtn);//StateBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showStateInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-11-25 11:54:36 +01:00
|
|
|
Intent goState = new Intent(MainActivity.this, StateActivity.class);
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-11-25 11:54:36 +01:00
|
|
|
MainActivity.this.startActivity(goState);
|
|
|
|
//webView.loadUrl(Constants.URL_DisApp_STATE);
|
|
|
|
//webView.setVisibility(View.VISIBLE);
|
|
|
|
//dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.HowtoBtn);//HowToBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showHowToInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-09 17:41:03 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2018-09-09 17:41:03 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_HOWTO);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
button = findViewById(R.id.AboudBtn);//AboutBtn
|
2018-09-13 16:58:36 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showAboutInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-07 20:22:31 +02:00
|
|
|
Intent goAbout = new Intent(MainActivity.this, AboutActivity.class);
|
2018-09-13 14:38:45 +02:00
|
|
|
//first time tap check
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
}
|
|
|
|
else
|
2018-09-07 20:22:31 +02:00
|
|
|
MainActivity.this.startActivity(goAbout);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2018-09-15 02:03:38 +02:00
|
|
|
|
|
|
|
ImageButton imageButton = findViewById(R.id.logo);//LogoBtn
|
|
|
|
imageButton.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showLogoInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-12-11 00:53:53 +01:00
|
|
|
|
2019-05-22 16:45:27 +02:00
|
|
|
//Status service
|
|
|
|
Intent intent = new Intent( MainActivity.this, StatusService.class);
|
|
|
|
startService(intent);
|
2019-04-02 14:58:35 +02:00
|
|
|
|
2019-05-26 01:01:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
//delete after version 1.1.6
|
|
|
|
PackageInfo info = null;
|
|
|
|
try {
|
|
|
|
info = getPackageManager().getPackageInfo(getPackageName(), 0);
|
|
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
|
|
// bad times
|
|
|
|
Log.e("MyApplication", "couldn't get package info!");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info == null) {
|
|
|
|
// can't do anything
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!firstStart.getBoolean("update", false)&&info.firstInstallTime != info.lastUpdateTime) {
|
|
|
|
showOptimzationInfo();
|
|
|
|
firstStart.edit().putBoolean("update", true).apply();
|
|
|
|
return;
|
|
|
|
}
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 01:01:54 +02:00
|
|
|
|
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
//Dialog windows
|
2018-09-20 16:44:19 +02:00
|
|
|
private void showChoose() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
//builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.ChooseChatTitle)
|
|
|
|
.setMessage(R.string.ChooseChat);
|
|
|
|
//LayoutInflater inflater = getLayoutInflater();
|
|
|
|
View view = View.inflate(this, R.layout.check_remember, null);
|
|
|
|
final CheckBox checkChat = (CheckBox) view.findViewById(R.id.checkChat);
|
|
|
|
checkChat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setPositiveButton(R.string.Conversations, new DialogInterface.OnClickListener() {
|
|
|
|
String Conversations = "eu.siacs.conversations";
|
|
|
|
Intent xmpp1 = getPackageManager().getLaunchIntentForPackage(Conversations);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
if (((CheckBox) checkChat).isChecked()) {
|
|
|
|
check.edit().putBoolean("checkConv", true).apply();
|
|
|
|
startActivity(xmpp1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
startActivity(xmpp1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.PixArt, new DialogInterface.OnClickListener() {
|
|
|
|
String PixArt = "de.pixart.messenger";
|
|
|
|
Intent xmpp2 = getPackageManager().getLaunchIntentForPackage(PixArt);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
if (((CheckBox) checkChat).isChecked()) {
|
|
|
|
check.edit().putBoolean("checkPix", true).apply();
|
|
|
|
startActivity(xmpp2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
startActivity(xmpp2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setView(view);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-13 14:38:45 +02:00
|
|
|
private void showFirstTap() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 14:38:45 +02:00
|
|
|
builder.setTitle(R.string.FirstTitle);
|
|
|
|
builder.setMessage(getString(R.string.FirstInfo));
|
2019-05-26 01:01:54 +02:00
|
|
|
builder.setPositiveButton(R.string.global_ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
showOptimzation();
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 14:38:45 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2019-05-26 01:01:54 +02:00
|
|
|
private void showOptimzation() {
|
|
|
|
Intent intent = new Intent();
|
|
|
|
String packageName = getPackageName();
|
|
|
|
PowerManager pm = (PowerManager) getSystemService( Context.POWER_SERVICE);
|
|
|
|
if (pm.isIgnoringBatteryOptimizations(packageName))
|
|
|
|
intent.setAction(Settings.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS);
|
|
|
|
else {
|
|
|
|
intent.setAction(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
|
|
|
|
intent.setData(Uri.parse("package:" + packageName));
|
|
|
|
}
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showOptimzationInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.OptimizationTitle);
|
|
|
|
builder.setMessage(getString(R.string.OptimizationInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
showOptimzation();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-09-13 16:58:36 +02:00
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View view) {
|
|
|
|
Toast.makeText(view.getContext(), R.string.activity_main_share_info, Toast.LENGTH_LONG).show();
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-20 16:44:19 +02:00
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
//Mail Info
|
|
|
|
private void showMailInfo() {
|
2018-09-15 02:03:38 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.MailInfoTitle);
|
|
|
|
builder.setMessage(getString(R.string.MailInfo));
|
|
|
|
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_K9HELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showMailDialog(){
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.MailDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
String k9 = "com.fsck.k9";
|
|
|
|
Intent mail = getPackageManager().getLaunchIntentForPackage(k9);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
mail = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + k9));
|
|
|
|
startActivity(mail);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
//Cloud Info
|
2018-09-08 03:39:01 +02:00
|
|
|
private void showCloudInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-08 03:39:01 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-09 17:41:03 +02:00
|
|
|
builder.setTitle(R.string.CloudInfoTitle);
|
|
|
|
builder.setMessage(getString(R.string.CloudInfo));
|
2018-09-08 03:39:01 +02:00
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_CLOUDHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showCloudDialog(){
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.CloudDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
String nc = "com.nextcloud.client";
|
|
|
|
Intent cloud = getPackageManager().getLaunchIntentForPackage(nc);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
cloud = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + nc));
|
|
|
|
startActivity(cloud);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
//Diaspora info
|
|
|
|
private void showDiaInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.DiasporaTitle);
|
|
|
|
builder.setMessage(getString(R.string.DiasporaInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setNegativeButton(R.string.tell_more, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_DIAHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showDiaDialog(){
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.DiasporaDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
String Diaspora = "com.github.dfa.diaspora_android";
|
|
|
|
Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
pod = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Diaspora));
|
|
|
|
startActivity(pod);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-09-13 16:58:36 +02:00
|
|
|
|
2018-09-16 22:00:20 +02:00
|
|
|
private void showForumInfo() {
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.ForumTitle);
|
|
|
|
builder.setMessage(getString(R.string.ForumInfo));
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_FORUMHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-20 16:44:19 +02:00
|
|
|
private void showForget() {
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.ForgetTitle);
|
|
|
|
if(check.getBoolean("checkConv", true)|| check.getBoolean("checkPix",true)) {
|
|
|
|
View view = View.inflate(this, R.layout.check_forget, null);
|
|
|
|
final CheckBox forgetChat = (CheckBox) view.findViewById(R.id.forgetChat);
|
|
|
|
forgetChat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
check.edit().putBoolean("checkConv", false).apply();
|
|
|
|
check.edit().putBoolean("checkPix", false).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setView(view);
|
|
|
|
}
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
private void showChatInfo() {
|
2018-09-15 02:03:38 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.ChatTitle);
|
|
|
|
builder.setMessage(getString(R.string.ChatInfo));
|
2018-09-20 16:44:19 +02:00
|
|
|
// ||check.getBoolean("checkPix", true)==true
|
|
|
|
if(check.getBoolean("checkConv", true)|| check.getBoolean("checkPix",true)) {
|
|
|
|
View view = View.inflate(this, R.layout.check_forget, null);
|
|
|
|
final CheckBox forgetChat = (CheckBox) view.findViewById(R.id.forgetChat);
|
|
|
|
forgetChat.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
|
@Override
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
check.edit().putBoolean("checkConv", false).apply();
|
|
|
|
check.edit().putBoolean("checkPix", false).apply();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setView(view);
|
|
|
|
}
|
2018-09-13 16:58:36 +02:00
|
|
|
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_XMPPHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showChatDialog(){
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.ChatDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
String Conversations = "eu.siacs.conversations";
|
|
|
|
Intent xmpp1 = getPackageManager().getLaunchIntentForPackage(Conversations);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
xmpp1 = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Conversations));
|
|
|
|
startActivity(xmpp1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-09-13 16:58:36 +02:00
|
|
|
|
2018-09-16 22:00:20 +02:00
|
|
|
private void showPadInfo() {
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.PadTitle);
|
|
|
|
builder.setMessage(getString(R.string.PadInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2019-03-24 11:02:21 +01:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
2018-09-16 22:00:20 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_PADHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showPAdDialog(){
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
2019-01-25 16:31:35 +01:00
|
|
|
builder.setMessage(getString(R.string.PadDialog));
|
2018-11-18 13:01:02 +01:00
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
String Padland = "com.mikifus.padland";
|
|
|
|
Intent pad = getPackageManager().getLaunchIntentForPackage(Padland);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
pad = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Padland));
|
|
|
|
startActivity(pad);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-09-16 22:00:20 +02:00
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
private void showCalcInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.CalcTitle);
|
|
|
|
builder.setMessage(getString(R.string.CalcInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2019-03-24 11:02:21 +01:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
2018-09-16 22:00:20 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_CALCHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showBinInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.BinTitle);
|
|
|
|
builder.setMessage(getString(R.string.BinInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_BINHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showUploadInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.UploadTitle);
|
|
|
|
builder.setMessage(getString(R.string.UploadInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-20 16:44:19 +02:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
2018-09-16 22:00:20 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_UPLOADHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showSearxInfo() {
|
2018-09-15 02:03:38 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.SearxTitle);
|
|
|
|
builder.setMessage(getString(R.string.SearxInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setNegativeButton(R.string.tell_more, new DialogInterface.OnClickListener() {
|
2018-09-13 16:58:36 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_SEARXHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showPollsInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.PollsTitle);
|
|
|
|
builder.setMessage(getString(R.string.PollsInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_POLLHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showBoardInfo() {
|
2018-09-16 22:00:20 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-13 16:58:36 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.BoardTitle);
|
|
|
|
builder.setMessage(getString(R.string.BoardInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2019-03-24 11:02:21 +01:00
|
|
|
builder.setNegativeButton(R.string.more_help, new DialogInterface.OnClickListener() {
|
2018-09-16 22:00:20 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_BOARDHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-12-18 21:00:58 +01:00
|
|
|
//There is no extra info about Nextcoud notes yet
|
|
|
|
private void showNotesInfo() {
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.NotesTitle);
|
|
|
|
builder.setMessage(getString(R.string.NotesInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
2018-12-30 10:52:32 +01:00
|
|
|
builder.setNegativeButton(R.string.tell_more, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_NOTESHELP);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
});
|
2018-12-18 21:00:58 +01:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
private void showNotesDialog(){
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.NotesDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
String NotesApp = "it.niedermann.owncloud.notes";
|
|
|
|
Intent notes = getPackageManager().getLaunchIntentForPackage(NotesApp);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
notes = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + NotesApp));
|
|
|
|
startActivity(notes);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
private void showUserInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-20 16:44:19 +02:00
|
|
|
builder.setCancelable(false)
|
|
|
|
.setTitle(R.string.UserTitle)
|
|
|
|
.setMessage(getString(R.string.UserInfo))
|
|
|
|
.setPositiveButton(R.string.global_ok, null);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showStateInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false)
|
|
|
|
.setTitle(R.string.StateTitle);
|
|
|
|
//.setMessage(getString(R.string.StateInfo));
|
|
|
|
LayoutInflater inflater = getLayoutInflater();
|
|
|
|
View view = inflater.inflate(R.layout.state_dialog, (ViewGroup) findViewById(R.id.StateView));
|
|
|
|
//xmppBtn
|
|
|
|
Button xmppBtn = view.findViewById(R.id.xmppBtn);
|
|
|
|
xmppBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
Uri uri = Uri.parse(String.valueOf(Constants.URL_DisApp_STATEXMPP));
|
|
|
|
Intent xmpp = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri)));
|
|
|
|
startActivity(xmpp);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
//MatrixBtn
|
|
|
|
Button matrixBtn = view.findViewById(R.id.matrixBtn);
|
|
|
|
matrixBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
Uri uri = Uri.parse(String.valueOf(Constants.URL_DisApp_STATEMATRIX));
|
|
|
|
Intent matrix = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri)));
|
|
|
|
startActivity(matrix);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
//SocialBtn
|
|
|
|
Button SocialBtn = view.findViewById(R.id.SocialBtn);
|
|
|
|
SocialBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
Uri uri = Uri.parse(String.valueOf(Constants.URL_DisApp_STATESOCIAL));
|
|
|
|
Intent social = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri)));
|
|
|
|
startActivity(social);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
//newsBtn
|
|
|
|
Button NewsBtn = view.findViewById(R.id.NewsBtn);
|
|
|
|
NewsBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
Uri uri = Uri.parse(String.valueOf(Constants.URL_DisApp_STATENEWS));
|
|
|
|
Intent news = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri)));
|
|
|
|
startActivity(news);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
//rssBtn
|
|
|
|
Button RssBtn = view.findViewById(R.id.RssBtn);
|
|
|
|
RssBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
Uri uri = Uri.parse(String.valueOf(Constants.URL_DisApp_STATERSS));
|
|
|
|
Intent rss = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri)));
|
|
|
|
startActivity(rss);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
builder.setView(view)
|
|
|
|
.setPositiveButton(R.string.global_ok, null)
|
|
|
|
.show();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
final SpannableString s;
|
|
|
|
s = new SpannableString(getString(R.string.StateInfo));
|
|
|
|
final TextView tx1=new TextView(MainActivity.this);
|
|
|
|
tx1.setText(s);
|
|
|
|
tx1.setAutoLinkMask(RESULT_OK);
|
|
|
|
tx1.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
|
|
|
|
Linkify.addLinks(s, Linkify.WEB_URLS);
|
|
|
|
builder.setTitle(R.string.StateTitle)
|
|
|
|
.setCancelable(false)
|
|
|
|
.setPositiveButton(R.string.global_ok, null);
|
|
|
|
//.setNegativeButton("Decline", new DialogInterface.OnClickListener() {
|
|
|
|
// public void onClick(DialogInterface dialog, int id) {
|
|
|
|
// finish();
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
builder.setView(tx1);
|
|
|
|
builder.show();*/
|
|
|
|
/* builder.setPositiveButton(R.string.global_ok, null);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setNegativeButton(R.string.state_help, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
Uri uri = Uri.parse(String.valueOf(Constants.URL_DisApp_STATEXMPP));
|
|
|
|
Intent xmpp = new Intent(Intent.ACTION_VIEW, Uri.parse(String.valueOf(uri)));
|
|
|
|
startActivity(xmpp);
|
|
|
|
}
|
|
|
|
});
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.show();*/
|
2018-09-13 16:58:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void showHowToInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.HowToTitle);
|
|
|
|
builder.setMessage(getString(R.string.HowToInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
2018-09-13 21:15:45 +02:00
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
private void showAboutInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.setTitle(R.string.AboutTitle);
|
|
|
|
builder.setMessage(getString(R.string.AboutInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
private void showLogoInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.setCancelable(false);
|
2018-09-15 02:03:38 +02:00
|
|
|
builder.setTitle(R.string.LogoTitle);
|
|
|
|
builder.setMessage(getString(R.string.LogoInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.setNegativeButton(R.string.LogoBtn, new DialogInterface.OnClickListener()
|
|
|
|
{
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
final AlertDialog dialog = builder.create();
|
|
|
|
dialog.show();
|
|
|
|
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setOnClickListener(new View.OnClickListener()
|
|
|
|
{int Counter = 0;
|
|
|
|
@Override
|
|
|
|
public void onClick(View v)
|
|
|
|
{
|
|
|
|
if (Counter < 10)
|
|
|
|
Counter++;
|
|
|
|
//first time tap check
|
|
|
|
if ((Counter == 10 )){
|
|
|
|
Intent goTap = new Intent(MainActivity.this, wsdfhjxc.taponium.MainActivity.class);
|
|
|
|
MainActivity.this.startActivity(goTap);
|
|
|
|
dialog.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
Button pbutton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
|
|
|
|
pbutton.setTextColor(Color.BLACK);
|
|
|
|
}
|
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
@Override
|
|
|
|
protected void onSaveInstanceState(Bundle outState) {
|
|
|
|
super.onSaveInstanceState(outState);
|
|
|
|
webView.saveState(outState);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onRestoreInstanceState(Bundle savedInstanceState) {
|
|
|
|
super.onRestoreInstanceState(savedInstanceState);
|
|
|
|
webView.restoreState(savedInstanceState);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
webView.onPause();
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.pauseTimers();
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onResume() {
|
|
|
|
super.onResume();
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.resumeTimers();
|
2018-09-02 19:00:45 +02:00
|
|
|
webView.onResume();
|
2018-09-09 17:41:03 +02:00
|
|
|
//inetnt filter get url from external
|
2018-09-15 02:03:38 +02:00
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-09 17:41:03 +02:00
|
|
|
Uri url = getIntent().getData();
|
|
|
|
if (url != null) {
|
|
|
|
Log.d("TAG", "URL Foud");
|
|
|
|
Log.d("TAG", "Url is :" + url);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
webView.loadUrl(url.toString());
|
|
|
|
}
|
|
|
|
//first start
|
|
|
|
if (firstStart.getBoolean("firstrun", true)) {
|
|
|
|
// Do first run stuff here then set 'firstrun' as false
|
2018-09-09 18:52:57 +02:00
|
|
|
Intent welcome = new Intent(MainActivity.this, WelcomeActivity.class);
|
|
|
|
MainActivity.this.startActivity(welcome);
|
2018-09-09 17:41:03 +02:00
|
|
|
// using the following line to edit/commit prefs
|
|
|
|
firstStart.edit().putBoolean("firstrun", false).apply();
|
|
|
|
}
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onStop() {
|
|
|
|
super.onStop();
|
|
|
|
disWebChromeClient.hideCustomView();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
|
|
|
if (disWebChromeClient.hideCustomView()) {
|
|
|
|
return true;
|
|
|
|
} else if (!disWebChromeClient.hideCustomView() && webView.canGoBack()) {
|
|
|
|
webView.goBack();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.onKeyDown(keyCode, event);
|
|
|
|
}
|
2018-09-30 00:08:57 +02:00
|
|
|
@Override
|
2018-09-20 16:44:19 +02:00
|
|
|
public boolean onPrepareOptionsMenu(Menu menu)
|
|
|
|
{
|
|
|
|
MenuItem register = menu.findItem(R.id.action_forget);
|
|
|
|
if(check.getBoolean("checkConv", true)||check.getBoolean("checkPix", true)) {
|
|
|
|
register.setVisible(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
register.setVisible(false);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
@Override
|
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
|
// Inflate the menu items for use in the action bar
|
|
|
|
MenuInflater inflater = getMenuInflater();
|
|
|
|
inflater.inflate(R.menu.menu_main, menu);
|
|
|
|
|
2018-09-20 16:44:19 +02:00
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
// To show icons in the actionbar's overflow menu:
|
|
|
|
// http://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar
|
|
|
|
//if(featureId == Window.FEATURE_ACTION_BAR && menu != null){
|
2018-09-22 12:14:39 +02:00
|
|
|
if(menu.getClass().getSimpleName().equals("MenuBuilder")) try {
|
|
|
|
Method m = menu.getClass().getDeclaredMethod(
|
|
|
|
"setOptionalIconsVisible", Boolean.TYPE);
|
|
|
|
m.setAccessible(true);
|
|
|
|
m.invoke(menu, true);
|
|
|
|
} catch (NoSuchMethodException e) {
|
|
|
|
Log.e(TAG, "onMenuOpened", e);
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new RuntimeException(e);
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return super.onCreateOptionsMenu(menu);
|
|
|
|
}
|
|
|
|
|
2018-09-09 17:41:03 +02:00
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
2018-09-15 02:03:38 +02:00
|
|
|
ScrollView dashboard = findViewById(R.id.dashboard);
|
2018-09-08 03:39:01 +02:00
|
|
|
TranslateAnimation animateup = new TranslateAnimation(0,0,-2*dashboard.getHeight(),0);
|
|
|
|
TranslateAnimation animatedown = new TranslateAnimation(0,0,0,-dashboard.getHeight());
|
2018-09-02 19:00:45 +02:00
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_share:
|
|
|
|
shareCurrentPage();
|
|
|
|
return true;
|
|
|
|
case R.id.action_home:
|
2018-09-08 03:39:01 +02:00
|
|
|
if(webView.getVisibility()==View.VISIBLE){
|
|
|
|
//animation
|
|
|
|
animateup.setDuration(500);
|
|
|
|
animateup.setFillAfter(false);
|
|
|
|
dashboard.startAnimation(animateup);
|
|
|
|
dashboard.setVisibility(View.VISIBLE);
|
|
|
|
webView.setVisibility(View.GONE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (webView.getVisibility()==View.GONE && webView.getUrl()!=null){
|
|
|
|
//animation
|
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(false);
|
|
|
|
dashboard.startAnimation(animatedown);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
2018-09-30 00:08:57 +02:00
|
|
|
case R.id.action_forget:
|
|
|
|
showForget();
|
2018-09-20 16:44:19 +02:00
|
|
|
|
2018-09-09 17:41:03 +02:00
|
|
|
case R.id.action_reload: {
|
|
|
|
String url = webView.getUrl();
|
|
|
|
webView.loadUrl(url);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
2018-09-09 17:41:03 +02:00
|
|
|
}
|
2019-05-26 01:01:54 +02:00
|
|
|
case R.id.action_optimization:
|
|
|
|
showOptimzation();
|
|
|
|
return true;
|
2018-09-02 19:00:45 +02:00
|
|
|
case R.id.action_about:
|
2018-09-07 20:22:31 +02:00
|
|
|
Intent goAbout = new Intent(MainActivity.this, AboutActivity.class);
|
|
|
|
MainActivity.this.startActivity(goAbout);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
2018-11-06 00:09:41 +01:00
|
|
|
case R.id.action_clear_cookies: {
|
|
|
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
|
|
|
CookieManager.getInstance().removeAllCookies(null);
|
|
|
|
}else{
|
|
|
|
CookieManager.getInstance().removeAllCookie();
|
|
|
|
}
|
|
|
|
}
|
2018-09-09 17:41:03 +02:00
|
|
|
return false;
|
2018-11-06 00:09:41 +01:00
|
|
|
case R.id.action_exit: {
|
|
|
|
moveTaskToBack(true);
|
|
|
|
finish();
|
|
|
|
return false;
|
2018-09-09 17:41:03 +02:00
|
|
|
}
|
2018-09-02 19:00:45 +02:00
|
|
|
default:
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
2018-09-22 12:14:39 +02:00
|
|
|
|
2018-09-13 14:38:45 +02:00
|
|
|
private void setupWebView(Bundle savedInstanceState, FrameLayout customViewContainer) {
|
2018-09-15 02:03:38 +02:00
|
|
|
disWebChromeClient = new DisWebChromeClient(webView, customViewContainer);
|
|
|
|
progressBar = findViewById(R.id.progressbarLoading);
|
|
|
|
webView = findViewById(R.id.webView_content);
|
2018-09-02 19:00:45 +02:00
|
|
|
webView.setWebChromeClient(disWebChromeClient);
|
|
|
|
webView.getSettings().setJavaScriptEnabled(true);
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.getSettings().setDomStorageEnabled(true);//solves taiga board \o/
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVerticalScrollBarEnabled(true);
|
2018-09-02 19:00:45 +02:00
|
|
|
webView.getSettings().setAppCacheEnabled(true);
|
|
|
|
webView.getSettings().setBuiltInZoomControls(true);
|
|
|
|
webView.getSettings().setSaveFormData(true);
|
2018-09-13 14:38:45 +02:00
|
|
|
webView.getSettings().setAllowFileAccess(true);
|
|
|
|
webView.getSettings().setLoadWithOverviewMode(true);
|
|
|
|
webView.getSettings().setUseWideViewPort(true);
|
2018-11-06 00:09:41 +01:00
|
|
|
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
|
|
|
|
webView.getSettings().setAllowContentAccess(true);
|
2018-09-07 20:22:31 +02:00
|
|
|
// webView.loadUrl(Constants.URL_DisApp_MAIN_PAGE);
|
2018-09-02 19:00:45 +02:00
|
|
|
webView.setOnLongClickListener(this);
|
2018-11-06 00:09:41 +01:00
|
|
|
// webView.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
//enable cookies
|
|
|
|
cookieManager = CookieManager.getInstance();
|
|
|
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
CookieSyncManager.createInstance(webView.getContext());
|
|
|
|
cookieManager.setAcceptCookie(true);
|
2018-11-22 21:26:34 +01:00
|
|
|
cookieManager.setAcceptThirdPartyCookies(webView,false);
|
2018-11-06 00:09:41 +01:00
|
|
|
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
|
|
|
|
}
|
|
|
|
CookieSyncManager syncManager = CookieSyncManager.createInstance(webView.getContext());
|
|
|
|
CookieManager cookieManager = CookieManager.getInstance();
|
|
|
|
String cookieString = "cookie_name=cookie_value; path=/";
|
|
|
|
String baseUrl="disroot.org";
|
|
|
|
cookieManager.setCookie(baseUrl, cookieString);
|
|
|
|
syncManager.sync();
|
|
|
|
String cookies = cookieManager.getCookie(baseUrl);
|
|
|
|
if (cookies != null) {
|
|
|
|
cookieManager.setCookie(baseUrl, cookies);
|
|
|
|
for (String c : cookies.split(";")) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
//Make download possible
|
|
|
|
webView.setDownloadListener(new DownloadListener() {
|
2018-09-13 21:15:45 +02:00
|
|
|
|
2018-09-13 21:30:45 +02:00
|
|
|
@TargetApi(Build.VERSION_CODES.M)
|
2018-09-13 14:38:45 +02:00
|
|
|
public void onDownloadStart(String url, String userAgent,
|
|
|
|
String contentDisposition, String mimetype,
|
|
|
|
long contentLength) {
|
2018-09-13 21:15:45 +02:00
|
|
|
//open dialog for permissions
|
|
|
|
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
|
== PackageManager.PERMISSION_GRANTED) {
|
|
|
|
Log.e("Permission error","You have permission");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Log.e("Permission error","You have asked for permission");
|
|
|
|
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
final String filename= URLUtil.guessFileName(url, contentDisposition, mimetype);
|
|
|
|
DownloadManager.Request request = new DownloadManager.Request(
|
|
|
|
Uri.parse(url));
|
|
|
|
request.allowScanningByMediaScanner();
|
|
|
|
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
|
|
|
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename);
|
|
|
|
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
|
2018-09-15 02:03:38 +02:00
|
|
|
assert dm != null;
|
2018-09-13 14:38:45 +02:00
|
|
|
dm.enqueue(request);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
if (Build.VERSION.SDK_INT >= 19) {
|
|
|
|
webView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
|
|
|
|
}
|
2018-09-15 02:03:38 +02:00
|
|
|
else webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
2018-09-13 14:38:45 +02:00
|
|
|
webView.setWebChromeClient(new ChromeClient());
|
|
|
|
webView.loadUrl(loadUrl); //change with your website
|
|
|
|
|
|
|
|
this.webView.setWebViewClient(new WebViewClient(){
|
|
|
|
@Override
|
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
|
super.onPageFinished(view, url);
|
|
|
|
progressBar.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPageStarted(WebView view, String url, Bitmap favicon) {
|
|
|
|
super.onPageStarted(view, url, favicon);
|
|
|
|
progressBar.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
2018-11-07 20:27:58 +01:00
|
|
|
if(url.startsWith("https")|url.startsWith("http")&&url.contains("disroot")&!url.contains("upload.disroot.org")) {
|
2018-09-15 02:03:38 +02:00
|
|
|
view.loadUrl(url);
|
|
|
|
return super.shouldOverrideUrlLoading(view, url);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
|
|
view.getContext().startActivity(intent);
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
});
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-13 14:38:45 +02:00
|
|
|
public boolean handleUrl(String url){
|
|
|
|
|
|
|
|
if (url.startsWith("geo:") || url.startsWith("mailto:") || url.startsWith("tel:") || url.startsWith("sms:")|| url.startsWith("xmpp:")) {
|
|
|
|
Intent searchAddress = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
|
|
|
|
startActivity(searchAddress);
|
|
|
|
}else
|
|
|
|
webView.loadUrl(url);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean checkAndRequestPermissions() {
|
|
|
|
int permissionCamera = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
|
|
|
|
int permissionStorage = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
|
|
List<String> listPermissionsNeeded = new ArrayList<>();
|
|
|
|
if (permissionStorage != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
listPermissionsNeeded.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
|
|
|
|
}
|
|
|
|
if (permissionCamera != PackageManager.PERMISSION_GRANTED) {
|
|
|
|
listPermissionsNeeded.add(Manifest.permission.CAMERA);
|
|
|
|
}
|
|
|
|
if (!listPermissionsNeeded.isEmpty()) {
|
|
|
|
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),REQUEST_ID_MULTIPLE_PERMISSIONS);
|
|
|
|
Log.e(TAG, "Returned falseeeee-------");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
Log.d(TAG, "Permission returned trueeeee-------");
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-09-15 02:03:38 +02:00
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
2018-09-13 14:38:45 +02:00
|
|
|
Log.d(TAG, "Permission callback called-------");
|
|
|
|
switch (requestCode) {
|
|
|
|
case REQUEST_ID_MULTIPLE_PERMISSIONS: {
|
|
|
|
|
|
|
|
Map<String, Integer> perms = new HashMap<>();
|
|
|
|
// Initialize the map with both permissions
|
|
|
|
perms.put(Manifest.permission.CAMERA, PackageManager.PERMISSION_GRANTED);
|
|
|
|
perms.put(Manifest.permission.WRITE_EXTERNAL_STORAGE, PackageManager.PERMISSION_GRANTED);
|
|
|
|
// Fill with actual results from user
|
|
|
|
if (grantResults.length > 0) {
|
|
|
|
for (int i = 0; i < permissions.length; i++)
|
|
|
|
perms.put(permissions[i], grantResults[i]);
|
|
|
|
// Check for both permissions
|
|
|
|
if (perms.get(Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
|
|
|
|
&& perms.get(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) {
|
|
|
|
Log.d(TAG, "camera & Storage permission granted");
|
|
|
|
Toast.makeText(this, "Permissions granted! Try now.", Toast.LENGTH_SHORT).show();
|
|
|
|
//chromClt.openChooser(chooserWV, chooserPathUri, chooserParams);
|
|
|
|
// process the normal flow
|
|
|
|
//else any one or both the permissions are not granted
|
|
|
|
} else {
|
|
|
|
Log.d(TAG, "Some permissions are not granted ask again ");
|
|
|
|
//permission is denied (this is the first time, when "never ask again" is not checked) so ask again explaining the usage of permission
|
|
|
|
// shouldShowRequestPermissionRationale will return true
|
|
|
|
//show the dialog or snackbar saying its necessary and try again otherwise proceed with setup.
|
|
|
|
if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.CAMERA) || ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
|
2018-09-15 02:03:38 +02:00
|
|
|
showDialogOK(new DialogInterface.OnClickListener() {
|
2018-09-13 14:38:45 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
switch (which) {
|
|
|
|
case DialogInterface.BUTTON_POSITIVE:
|
|
|
|
checkAndRequestPermissions();
|
|
|
|
break;
|
|
|
|
case DialogInterface.BUTTON_NEGATIVE:
|
|
|
|
// proceed with logic by disabling the related features or quit the app.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//permission is denied (and never ask again is checked)
|
|
|
|
//shouldShowRequestPermissionRationale will return false
|
|
|
|
else {
|
|
|
|
Toast.makeText(this, "Go to settings and enable permissions", Toast.LENGTH_LONG).show();
|
|
|
|
// //proceed with logic by disabling the related features or quit the app.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
private void showDialogOK(DialogInterface.OnClickListener okListener) {
|
2018-09-13 14:38:45 +02:00
|
|
|
new AlertDialog.Builder(this)
|
2018-09-15 02:03:38 +02:00
|
|
|
.setMessage("Camera and Storage Permission required for this app")
|
2018-09-13 14:38:45 +02:00
|
|
|
.setPositiveButton("OK", okListener)
|
|
|
|
.setNegativeButton("Cancel", okListener)
|
|
|
|
.create()
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
|
|
|
if (requestCode != INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Uri[] results = null;
|
|
|
|
// Check that the response is a good one
|
|
|
|
if (resultCode == MainActivity.RESULT_OK) {
|
|
|
|
if (data == null) {
|
|
|
|
// If there is not data, then we may have taken a photo
|
|
|
|
if (mCameraPhotoPath != null) {
|
|
|
|
results = new Uri[]{Uri.parse(mCameraPhotoPath)};
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
String dataString = data.getDataString();
|
|
|
|
if (dataString != null) {
|
|
|
|
results = new Uri[]{Uri.parse(dataString)};
|
|
|
|
}else {
|
2018-09-15 02:03:38 +02:00
|
|
|
if (data.getClipData() != null) {
|
|
|
|
final int numSelectedFiles = data.getClipData().getItemCount();
|
2018-09-13 14:38:45 +02:00
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
results = new Uri[numSelectedFiles];
|
2018-09-13 14:38:45 +02:00
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
for (int i = 0; i < numSelectedFiles; i++) {
|
|
|
|
results[i] = data.getClipData().getItemAt(i).getUri();
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mFilePathCallback.onReceiveValue(results);
|
|
|
|
mFilePathCallback = null;
|
|
|
|
} else if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
|
|
|
|
if (requestCode != FILECHOOSER_RESULTCODE || mUploadMessage == null) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data);
|
|
|
|
return;
|
|
|
|
}
|
2018-09-15 02:03:38 +02:00
|
|
|
Uri result = null;
|
|
|
|
try {
|
|
|
|
if (resultCode != RESULT_OK) {
|
|
|
|
result = null;
|
|
|
|
} else {
|
|
|
|
// retrieve from the private variable if the intent is null
|
|
|
|
result = data == null ? mCapturedImageURI : data.getData();
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
2018-09-15 02:03:38 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
Toast.makeText(getApplicationContext(), "activity :" + e,
|
|
|
|
Toast.LENGTH_LONG).show();
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
2018-09-15 02:03:38 +02:00
|
|
|
mUploadMessage.onReceiveValue(result);
|
|
|
|
mUploadMessage = null;
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
if (Build.VERSION.SDK_INT >= 23) {
|
|
|
|
if (checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
|
|
|
|
== PackageManager.PERMISSION_GRANTED) {
|
|
|
|
Log.e("Permission error","You have permission");
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Log.e("Permission error","You have asked for permission");
|
|
|
|
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { //you dont need to worry about these stuff below api level 23
|
|
|
|
Log.e("Permission error","You already have the permission");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private File createImageFile() throws IOException {
|
|
|
|
// Create an image file name
|
2018-09-22 12:14:39 +02:00
|
|
|
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
|
2018-09-13 14:38:45 +02:00
|
|
|
String imageFileName = "JPEG_" + timeStamp + "_";
|
|
|
|
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
|
2018-09-15 02:03:38 +02:00
|
|
|
return File.createTempFile(
|
2018-09-13 14:38:45 +02:00
|
|
|
imageFileName, /* prefix */
|
|
|
|
".jpg", /* suffix */
|
|
|
|
storageDir /* directory */
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
2018-09-13 14:38:45 +02:00
|
|
|
public class ChromeClient extends WebChromeClient {
|
|
|
|
|
|
|
|
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
|
|
|
|
// callback.invoke(String origin, boolean allow, boolean remember);
|
|
|
|
Log.e(TAG, "onGeolocationPermissionsShowPrompt: " );
|
|
|
|
callback.invoke(origin, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// For Android 5.0
|
|
|
|
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
|
|
|
|
|
|
|
|
chooserWV = view;
|
|
|
|
chooserPathUri = filePath;
|
|
|
|
chooserParams = fileChooserParams;
|
|
|
|
|
|
|
|
if(checkAndRequestPermissions()){
|
2018-09-15 02:03:38 +02:00
|
|
|
openChooser(chooserPathUri);
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
void openChooser(ValueCallback<Uri[]> filePath){
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
// Double check that we don't have any existing callbacks
|
|
|
|
if (mFilePathCallback != null) {
|
|
|
|
mFilePathCallback.onReceiveValue(null);
|
|
|
|
}
|
|
|
|
mFilePathCallback = filePath;
|
|
|
|
Intent takePictureIntent;
|
|
|
|
|
|
|
|
takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
|
|
|
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
|
|
|
|
// Create the File where the photo should go
|
|
|
|
File photoFile = null;
|
|
|
|
try {
|
|
|
|
photoFile = createImageFile();
|
|
|
|
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
|
|
|
|
} catch (IOException ex) {
|
|
|
|
// Error occurred while creating the File
|
|
|
|
Log.e(TAG, "Unable to create Image File", ex);
|
|
|
|
}
|
|
|
|
// Continue only if the File was successfully created
|
|
|
|
if (photoFile != null) {
|
|
|
|
mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
|
|
|
|
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
|
|
|
|
} else {
|
|
|
|
takePictureIntent = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
if (Build.VERSION.SDK_INT >= 18) {
|
|
|
|
contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
|
|
|
}
|
|
|
|
contentSelectionIntent.setType("*/*");
|
|
|
|
Intent[] intentArray;
|
|
|
|
if (takePictureIntent != null) {
|
|
|
|
intentArray = new Intent[]{takePictureIntent};
|
|
|
|
} else {
|
|
|
|
intentArray = new Intent[0];
|
|
|
|
}
|
|
|
|
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
|
|
|
|
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
|
|
|
|
}
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
/* openFileChooser for Android 3.0+ */
|
|
|
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
|
|
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
|
2018-09-13 14:38:45 +02:00
|
|
|
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType) {
|
|
|
|
|
|
|
|
mUploadMessage = uploadMsg;
|
|
|
|
// Create AndroidExampleFolder at sdcard
|
|
|
|
// Create AndroidExampleFolder at sdcard
|
|
|
|
File imageStorageDir = new File(Environment.getExternalStoragePublicDirectory(
|
|
|
|
Environment.DIRECTORY_PICTURES)
|
|
|
|
, "AndroidExampleFolder");
|
|
|
|
if (!imageStorageDir.exists()) {
|
|
|
|
// Create AndroidExampleFolder at sdcard
|
2018-09-15 02:03:38 +02:00
|
|
|
boolean mkdirs = imageStorageDir.mkdirs();
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
// Create camera captured image file path and name
|
|
|
|
File file = new File(
|
|
|
|
imageStorageDir + File.separator + "IMG_"
|
|
|
|
+ String.valueOf(System.currentTimeMillis())
|
|
|
|
+ ".jpg");
|
|
|
|
mCapturedImageURI = Uri.fromFile(file);
|
|
|
|
// Camera capture image intent
|
|
|
|
final Intent captureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
|
|
|
|
captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
|
|
|
|
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
|
|
|
|
i.addCategory(Intent.CATEGORY_OPENABLE);
|
|
|
|
i.setType("image/*");
|
|
|
|
// Create file chooser intent
|
|
|
|
Intent chooserIntent = Intent.createChooser(i, "Image Chooser");
|
|
|
|
// Set camera intent to file chooser
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Parcelable[]{captureIntent});
|
|
|
|
// On select image call onActivityResult method of activity
|
|
|
|
|
|
|
|
chooserIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
|
|
|
startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
|
|
|
|
}
|
|
|
|
|
|
|
|
// openFileChooser for Android < 3.0
|
2018-09-15 02:03:38 +02:00
|
|
|
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
|
2018-09-13 14:38:45 +02:00
|
|
|
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
|
|
|
|
openFileChooser(uploadMsg, "");
|
|
|
|
}
|
|
|
|
|
|
|
|
//openFileChooser for other Android versions
|
2018-09-15 02:03:38 +02:00
|
|
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
|
|
|
|
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
|
2018-09-13 14:38:45 +02:00
|
|
|
public void openFileChooser(ValueCallback<Uri> uploadMsg,
|
|
|
|
String acceptType,
|
|
|
|
String capture) {
|
|
|
|
openFileChooser(uploadMsg, acceptType);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
public void shareCurrentPage() {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
|
|
|
intent.setAction(Intent.ACTION_SEND);
|
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, webView.getUrl());
|
|
|
|
intent.setType("text/plain");
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
2018-12-11 00:53:53 +01:00
|
|
|
|
2019-02-18 20:25:22 +01:00
|
|
|
//show snackbar to avoid exit on backpress
|
|
|
|
@Override
|
|
|
|
public void onBackPressed() {
|
|
|
|
ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
FragmentManager manager = getSupportFragmentManager();
|
|
|
|
if (dashboard.getVisibility() == View.GONE){
|
|
|
|
dashboard.setVisibility(View.VISIBLE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (manager.getBackStackEntryCount() > 0) {
|
|
|
|
super.onBackPressed();
|
|
|
|
} else {
|
|
|
|
snackbarExitApp.show();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|