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;
|
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;
|
2020-01-09 19:33:07 +01:00
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
import de.cketti.library.changelog.ChangeLog;
|
|
|
|
|
2018-09-15 02:03:38 +02:00
|
|
|
@SuppressWarnings("ALL")
|
2020-01-09 19:33:07 +01:00
|
|
|
public class MainActivity extends AppCompatActivity implements View.OnLongClickListener,View.OnClickListener {
|
2018-09-02 19:00:45 +02:00
|
|
|
|
2018-09-09 17:41:03 +02:00
|
|
|
SharedPreferences firstStart = null;//first start
|
2018-09-20 16:44:19 +02:00
|
|
|
SharedPreferences check = null;
|
2020-01-13 03:26:44 +01:00
|
|
|
SharedPreferences BtnPreference;
|
2020-01-09 19:33:07 +01:00
|
|
|
WebChromeClient.FileChooserParams chooserParams;
|
|
|
|
ValueCallback<Uri[]> chooserPathUri;
|
|
|
|
Button button;
|
2020-01-17 21:43:42 +01:00
|
|
|
private Button MailBtn,CloudBtn,ForumBtn,ChatBtn,PadBtn,CalcBtn,BinBtn,UploadBtn,SearxBtn,PollsBtn,BoardBtn,CallsBtn,NotesBtn,GitBtn,UserBtn,StateBtn,HowToBtn,AboutBtn;//all buttons
|
2020-01-09 19:33:07 +01:00
|
|
|
private CookieManager cookieManager;
|
|
|
|
private WebView webView;
|
|
|
|
private DisWebChromeClient disWebChromeClient;
|
2018-09-13 14:38:45 +02:00
|
|
|
private ValueCallback<Uri> mUploadMessage;
|
|
|
|
private Uri mCapturedImageURI = null;
|
|
|
|
private ValueCallback<Uri[]> mFilePathCallback;
|
|
|
|
private ProgressBar progressBar;
|
2018-09-14 09:44:30 +02:00
|
|
|
private Handler handler = new Handler();
|
2019-02-18 20:25:22 +01:00
|
|
|
private Snackbar snackbarExitApp;
|
|
|
|
private FragmentManager fm;
|
2020-01-09 19:33:07 +01:00
|
|
|
private String mCameraPhotoPath;
|
|
|
|
private String loadUrl;
|
|
|
|
private int progressStatus = 0;
|
2018-11-06 00:09:41 +01:00
|
|
|
|
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);
|
2020-01-18 20:31:34 +01:00
|
|
|
toolbar.setNavigationIcon( R.drawable.ic_home );
|
|
|
|
toolbar.setNavigationOnClickListener( new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
TranslateAnimation animateup = new TranslateAnimation(0,0,-2*dashboard.getHeight(),0);
|
|
|
|
TranslateAnimation animatedown = new TranslateAnimation(0,0,0,-dashboard.getHeight());
|
|
|
|
if(webView.getVisibility()==View.VISIBLE){
|
|
|
|
//animation
|
|
|
|
animateup.setDuration(500);
|
|
|
|
animateup.setFillAfter(false);
|
|
|
|
dashboard.startAnimation(animateup);
|
|
|
|
dashboard.setVisibility(View.VISIBLE);
|
|
|
|
webView.setVisibility(View.GONE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (webView.getVisibility()==View.GONE && webView.getUrl()!=null){
|
|
|
|
//animation
|
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(false);
|
|
|
|
dashboard.startAnimation(animatedown);
|
|
|
|
hideDashboard();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} );
|
|
|
|
|
2018-09-13 14:38:45 +02:00
|
|
|
setupWebView(savedInstanceState, frameLayoutContainer);
|
2020-01-09 19:33:07 +01:00
|
|
|
//settings
|
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);
|
2020-01-13 03:26:44 +01:00
|
|
|
//buttons visiblility preference
|
2020-01-14 19:17:45 +01:00
|
|
|
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( "BinBtn", Context.MODE_PRIVATE );//bin
|
|
|
|
BtnPreference = getSharedPreferences( "UploadBtn", Context.MODE_PRIVATE );//upload
|
|
|
|
BtnPreference = getSharedPreferences( "SearxBtn", Context.MODE_PRIVATE );//search
|
2020-01-15 19:02:03 +01:00
|
|
|
BtnPreference = getSharedPreferences( "PollsBtn", Context.MODE_PRIVATE );//polls
|
2020-01-17 21:43:42 +01:00
|
|
|
BtnPreference = getSharedPreferences( "BoardBtn", Context.MODE_PRIVATE );//board
|
|
|
|
BtnPreference = getSharedPreferences( "CallsBtn", Context.MODE_PRIVATE );//calls
|
|
|
|
BtnPreference = getSharedPreferences( "NotesBtn", Context.MODE_PRIVATE );//notes
|
|
|
|
BtnPreference = getSharedPreferences( "GitBtn", Context.MODE_PRIVATE );//git
|
|
|
|
BtnPreference = getSharedPreferences( "UserBtn", Context.MODE_PRIVATE );//user
|
|
|
|
BtnPreference = getSharedPreferences( "HowToBtn", Context.MODE_PRIVATE );//howTo
|
|
|
|
BtnPreference = getSharedPreferences( "AboutBtn", Context.MODE_PRIVATE );//about
|
2020-01-09 19:33:07 +01:00
|
|
|
//Status service
|
|
|
|
Intent intent = new Intent( MainActivity.this, StatusService.class);
|
|
|
|
startService(intent);
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2020-01-09 19:33:07 +01:00
|
|
|
// Link the button in activity_main.xml
|
|
|
|
MailBtn = findViewById( R.id.MailBtn );
|
|
|
|
CloudBtn = findViewById( R.id.CloudBtn );
|
2020-01-13 03:26:44 +01:00
|
|
|
//DiasporaBtn = findViewById( R.id.DiasporaBtn );//end of Disroot's Dandelion
|
2020-01-09 19:33:07 +01:00
|
|
|
ForumBtn = findViewById( R.id.ForumBtn );
|
|
|
|
ChatBtn = findViewById( R.id.ChatBtn );
|
|
|
|
PadBtn = findViewById( R.id.PadBtn );
|
|
|
|
CalcBtn = findViewById( R.id.CalcBtn );
|
|
|
|
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 );
|
2020-01-17 21:43:42 +01:00
|
|
|
CallsBtn = findViewById( R.id.CallsBtn );
|
2020-01-09 19:33:07 +01:00
|
|
|
NotesBtn = findViewById( R.id.NotesBtn );
|
2020-01-17 21:43:42 +01:00
|
|
|
GitBtn = findViewById( R.id.GitBtn );
|
2020-01-09 19:33:07 +01:00
|
|
|
UserBtn = findViewById( R.id.UserBtn );
|
|
|
|
StateBtn = findViewById( R.id.StateBtn );
|
|
|
|
HowToBtn = findViewById( R.id.HowToBtn );
|
|
|
|
AboutBtn = findViewById( R.id.AboutBtn );
|
|
|
|
|
2020-01-14 19:17:45 +01:00
|
|
|
Map<String, ?> allEntries = BtnPreference.getAll();
|
|
|
|
for (Map.Entry<String, ?> entry : allEntries.entrySet()) {
|
|
|
|
if (entry.getValue().equals( false )){
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
2020-01-17 21:43:42 +01:00
|
|
|
for(int i=0; i<Constants.buttonIDs.length; i++) {
|
|
|
|
Button b = (Button) findViewById(Constants.buttonIDs[i]);
|
2020-01-14 19:17:45 +01:00
|
|
|
int resID = getResources().getIdentifier(entry.getKey(),
|
|
|
|
"id", getPackageName());
|
|
|
|
if(findViewById(resID)==b) {
|
|
|
|
viewGroup.removeView(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-13 03:26:44 +01:00
|
|
|
}
|
|
|
|
|
2020-01-14 19:17:45 +01:00
|
|
|
//get preferences
|
|
|
|
|
|
|
|
|
2020-01-09 19:33:07 +01:00
|
|
|
//Set longclick buttons
|
|
|
|
MailBtn.setOnLongClickListener( this );
|
|
|
|
CloudBtn.setOnLongClickListener( this );
|
2020-01-13 03:26:44 +01:00
|
|
|
//DiasporaBtn.setOnLongClickListener( this );//end of Disroot's Dandelion
|
2020-01-09 19:33:07 +01:00
|
|
|
ForumBtn.setOnLongClickListener( this );
|
|
|
|
ChatBtn.setOnLongClickListener( this );
|
|
|
|
PadBtn.setOnLongClickListener( this );
|
|
|
|
CalcBtn.setOnLongClickListener( this );
|
|
|
|
BinBtn.setOnLongClickListener( this );
|
|
|
|
UploadBtn.setOnLongClickListener( this );
|
|
|
|
SearxBtn.setOnLongClickListener( this );
|
|
|
|
PollsBtn.setOnLongClickListener( this );
|
|
|
|
BoardBtn.setOnLongClickListener( this );
|
2020-01-17 21:43:42 +01:00
|
|
|
CallsBtn.setOnLongClickListener( this );
|
2020-01-09 19:33:07 +01:00
|
|
|
NotesBtn.setOnLongClickListener( this );
|
2020-01-17 21:43:42 +01:00
|
|
|
GitBtn.setOnLongClickListener( this );
|
2020-01-09 19:33:07 +01:00
|
|
|
UserBtn.setOnLongClickListener( this );
|
|
|
|
StateBtn.setOnLongClickListener( this );
|
|
|
|
HowToBtn.setOnLongClickListener( this );
|
|
|
|
AboutBtn.setOnLongClickListener( this );
|
|
|
|
|
|
|
|
//set clickbuttons
|
|
|
|
MailBtn.setOnClickListener( this );
|
|
|
|
CloudBtn.setOnClickListener( this );
|
2020-01-13 03:26:44 +01:00
|
|
|
//DiasporaBtn.setOnClickListener( this );//end of Disroot's Dandelion
|
2020-01-09 19:33:07 +01:00
|
|
|
ForumBtn.setOnClickListener( this );
|
|
|
|
ChatBtn.setOnClickListener( this );
|
|
|
|
PadBtn.setOnClickListener( this );
|
|
|
|
CalcBtn.setOnClickListener( this );
|
|
|
|
BinBtn.setOnClickListener( this );
|
|
|
|
UploadBtn.setOnClickListener( this );
|
|
|
|
SearxBtn.setOnClickListener( this );
|
|
|
|
PollsBtn.setOnClickListener( this );
|
|
|
|
BoardBtn.setOnClickListener( this );
|
2020-01-17 21:43:42 +01:00
|
|
|
CallsBtn.setOnClickListener( this );
|
2020-01-09 19:33:07 +01:00
|
|
|
NotesBtn.setOnClickListener( this );
|
2020-01-17 21:43:42 +01:00
|
|
|
GitBtn.setOnClickListener( this );
|
2020-01-09 19:33:07 +01:00
|
|
|
UserBtn.setOnClickListener( this );
|
|
|
|
StateBtn.setOnClickListener( this );
|
|
|
|
HowToBtn.setOnClickListener( this );
|
|
|
|
AboutBtn.setOnClickListener( this );
|
2018-09-30 21:32:56 +02:00
|
|
|
|
2020-01-09 19:33:07 +01:00
|
|
|
ImageButton imageButton = findViewById(R.id.logo);//LogoBtn
|
|
|
|
imageButton.setOnLongClickListener(new View.OnLongClickListener() {
|
2018-09-13 16:58:36 +02:00
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
2020-01-09 19:33:07 +01:00
|
|
|
showLogoInfo();
|
2018-09-13 16:58:36 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2020-01-09 19:33:07 +01:00
|
|
|
}
|
2018-09-08 03:39:01 +02:00
|
|
|
|
2020-01-09 19:33:07 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(View view){
|
|
|
|
if (firstStart.getBoolean("firsttap", true)){
|
|
|
|
showFirstTap();
|
|
|
|
firstStart.edit().putBoolean("firsttap", false).apply();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (view.getId()) {
|
|
|
|
case R.id.MailBtn:
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent mail = getPackageManager().getLaunchIntentForPackage( Constants.k9 );
|
2020-01-09 19:33:07 +01:00
|
|
|
if (mail == null) {
|
|
|
|
showMailDialog();
|
|
|
|
break;
|
|
|
|
} else startActivity(mail);
|
|
|
|
break;
|
|
|
|
case R.id.CloudBtn:
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent cloud = getPackageManager().getLaunchIntentForPackage(Constants.nc);
|
2020-01-09 19:33:07 +01:00
|
|
|
if(cloud == null) {
|
|
|
|
showCloudDialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else startActivity(cloud);
|
|
|
|
break;
|
2020-01-13 03:26:44 +01:00
|
|
|
/*case R.id.DiasporaBtn: //end ofDisroot's Dandelion
|
2020-01-09 19:33:07 +01:00
|
|
|
Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora);
|
|
|
|
if(getPackageManager().getLaunchIntentForPackage(Diaspora) == null) {
|
|
|
|
showDiaDialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else startActivity(pod);
|
2020-01-13 03:26:44 +01:00
|
|
|
break;*/
|
2020-01-09 19:33:07 +01:00
|
|
|
case R.id.ForumBtn:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_FORUM);
|
|
|
|
hideDashboard();
|
|
|
|
break;
|
|
|
|
case R.id.ChatBtn:
|
|
|
|
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent xmpp1 = getPackageManager().getLaunchIntentForPackage(Constants.Conversations);
|
|
|
|
Intent xmpp2 = getPackageManager().getLaunchIntentForPackage(Constants.PixArt);
|
2020-01-09 19:33:07 +01:00
|
|
|
if((xmpp1 == null)&&(xmpp2 == null)) {
|
|
|
|
showChatDialog();
|
|
|
|
break;
|
2018-09-20 16:44:19 +02:00
|
|
|
}
|
2020-01-09 19:33:07 +01:00
|
|
|
if((xmpp1 == null)&&(xmpp2 != null)) {
|
2018-09-20 16:44:19 +02:00
|
|
|
startActivity(xmpp2);
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if((xmpp1 != null)&&(xmpp2 != null)) {
|
|
|
|
if(check.getBoolean("checkConv", Boolean.parseBoolean(null))||check.getBoolean("checkConv", false)) {
|
|
|
|
startActivity(xmpp1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(check.getBoolean("checkPix", Boolean.parseBoolean(null))||check.getBoolean("checkPix", false)) {
|
|
|
|
startActivity(xmpp2);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
showChoose();
|
|
|
|
break;
|
2018-09-20 16:44:19 +02:00
|
|
|
}
|
|
|
|
else
|
2020-01-09 19:33:07 +01:00
|
|
|
startActivity(xmpp1);
|
|
|
|
break;
|
|
|
|
case R.id.PadBtn:
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent pad = getPackageManager().getLaunchIntentForPackage(Constants.Padland);
|
2020-01-09 19:33:07 +01:00
|
|
|
if(pad == null) {
|
|
|
|
showPAdDialog();
|
|
|
|
break;
|
2018-09-20 16:44:19 +02:00
|
|
|
}
|
2020-01-09 19:33:07 +01:00
|
|
|
else startActivity(pad);
|
|
|
|
break;
|
|
|
|
case R.id.CalcBtn:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_CALC);
|
|
|
|
hideDashboard();
|
|
|
|
break;
|
|
|
|
case R.id.BinBtn:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_BIN);
|
|
|
|
hideDashboard();
|
|
|
|
break;
|
|
|
|
case R.id.UploadBtn:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_UPLOAD);
|
|
|
|
hideDashboard();
|
|
|
|
break;
|
|
|
|
case R.id.SearxBtn:
|
|
|
|
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();
|
|
|
|
break;
|
2020-01-17 21:43:42 +01:00
|
|
|
case R.id.CallsBtn:
|
|
|
|
Intent board = getPackageManager().getLaunchIntentForPackage(Constants.CallsApp);
|
|
|
|
if(board == null) {
|
|
|
|
showBoardDialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else startActivity(board);
|
|
|
|
break;
|
2020-01-09 19:33:07 +01:00
|
|
|
case R.id.NotesBtn:
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent notes = getPackageManager().getLaunchIntentForPackage(Constants.NotesApp);
|
2020-01-09 19:33:07 +01:00
|
|
|
if(notes == null) {
|
|
|
|
showNotesDialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else startActivity(notes);
|
|
|
|
break;
|
2020-01-17 21:43:42 +01:00
|
|
|
case R.id.GitBtn:
|
|
|
|
Intent git = getPackageManager().getLaunchIntentForPackage(Constants.GitApp);
|
|
|
|
if(git == null) {
|
|
|
|
showGitDialog();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else startActivity(git);
|
|
|
|
break;
|
2020-01-09 19:33:07 +01:00
|
|
|
case R.id.UserBtn:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_USER);
|
|
|
|
hideDashboard();
|
|
|
|
break;
|
|
|
|
case R.id.StateBtn:
|
|
|
|
Intent goState = new Intent(MainActivity.this, StateActivity.class);
|
|
|
|
MainActivity.this.startActivity(goState);
|
|
|
|
break;
|
|
|
|
case R.id.HowToBtn:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_HOWTO);
|
|
|
|
hideDashboard();
|
|
|
|
break;
|
|
|
|
case R.id.AboutBtn:
|
|
|
|
Intent goAbout = new Intent(MainActivity.this, AboutActivity.class);
|
|
|
|
MainActivity.this.startActivity(goAbout);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
2020-01-09 19:33:07 +01:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View view) {
|
|
|
|
switch (view.getId()) {
|
|
|
|
case R.id.MailBtn:
|
|
|
|
showMailInfo();
|
|
|
|
break;
|
|
|
|
case R.id.CloudBtn:
|
|
|
|
showCloudInfo();
|
|
|
|
break;
|
2020-01-13 03:26:44 +01:00
|
|
|
/*case R.id.DiasporaBtn://end of Disroot's Dandelion
|
2020-01-09 19:33:07 +01:00
|
|
|
showDiaInfo();
|
2020-01-13 03:26:44 +01:00
|
|
|
break;*/
|
2020-01-09 19:33:07 +01:00
|
|
|
case R.id.ForumBtn:
|
|
|
|
showForumInfo();
|
|
|
|
break;
|
|
|
|
case R.id.ChatBtn:
|
|
|
|
showChatInfo();
|
|
|
|
break;
|
|
|
|
case R.id.PadBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showPadInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.CalcBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showCalcInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.BinBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showBinInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.UploadBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showUploadInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.SearxBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showSearxInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.PollsBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showPollsInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.BoardBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showBoardInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
2020-01-17 21:43:42 +01:00
|
|
|
case R.id.CallsBtn:
|
|
|
|
showCallsInfo();
|
|
|
|
break;
|
2020-01-09 19:33:07 +01:00
|
|
|
case R.id.NotesBtn:
|
2018-12-18 21:00:58 +01:00
|
|
|
showNotesInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
2020-01-17 21:43:42 +01:00
|
|
|
case R.id.GitBtn:
|
|
|
|
showGitInfo();
|
|
|
|
break;
|
2020-01-09 19:33:07 +01:00
|
|
|
case R.id.UserBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showUserInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.StateBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showStateInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.HowToBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showHowToInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
case R.id.AboutBtn:
|
2018-09-13 16:58:36 +02:00
|
|
|
showAboutInfo();
|
2020-01-09 19:33:07 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
Toast.makeText(view.getContext(), R.string.activity_main_share_info, Toast.LENGTH_LONG).show();
|
2019-05-26 01:01:54 +02:00
|
|
|
}
|
2020-01-09 19:33:07 +01:00
|
|
|
return false;
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
2020-01-09 19:33:07 +01:00
|
|
|
//Dialog windows
|
2019-05-26 01:01:54 +02:00
|
|
|
|
2020-01-09 19:33:07 +01:00
|
|
|
//hide Dashboard
|
|
|
|
private void hideDashboard() {
|
|
|
|
final ScrollView dashboard = findViewById(R.id.dashboard);
|
|
|
|
webView.setVisibility( View.VISIBLE );
|
|
|
|
dashboard.setVisibility( View.GONE );
|
|
|
|
}
|
2019-05-26 01:01:54 +02:00
|
|
|
|
2020-01-13 03:26:44 +01:00
|
|
|
//Show chat choice
|
2018-09-20 16:44:19 +02:00
|
|
|
private void showChoose() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setTitle(R.string.ChooseChatTitle)
|
|
|
|
.setMessage(R.string.ChooseChat);
|
|
|
|
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() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent xmpp1 = getPackageManager().getLaunchIntentForPackage(Constants.Conversations);
|
2018-09-20 16:44:19 +02:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
if (((CheckBox) checkChat).isChecked()) {
|
2020-01-09 19:33:07 +01:00
|
|
|
check.edit().putBoolean("checkConv", true).apply();
|
|
|
|
startActivity(xmpp1);
|
|
|
|
return;
|
2018-09-20 16:44:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
startActivity(xmpp1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.PixArt, new DialogInterface.OnClickListener() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent xmpp2 = getPackageManager().getLaunchIntentForPackage(Constants.PixArt);
|
2018-09-20 16:44:19 +02:00
|
|
|
@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() {
|
2020-01-09 19:33:07 +01:00
|
|
|
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);
|
2019-05-26 01:01:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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-20 16:44:19 +02:00
|
|
|
|
2018-09-13 16:58:36 +02:00
|
|
|
//Mail Info
|
|
|
|
private void showMailInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-13 16:58:36 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-13 03:26:44 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.MailBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(MailBtn);
|
2020-01-14 19:17:45 +01:00
|
|
|
BtnPreference.edit().putBoolean( "MailBtn", false ).apply();
|
2020-01-13 03:26:44 +01:00
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showMailDialog(){
|
|
|
|
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() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent mail = getPackageManager().getLaunchIntentForPackage(Constants.k9);
|
2018-11-18 13:01:02 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2020-01-17 21:43:42 +01:00
|
|
|
mail = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.k9));
|
2018-11-18 13:01:02 +01:00
|
|
|
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() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-13 03:26:44 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.CloudBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(CloudBtn);
|
2020-01-14 19:17:45 +01:00
|
|
|
BtnPreference.edit().putBoolean( "CloudBtn", false ).apply();
|
2020-01-13 03:26:44 +01:00
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showCloudDialog(){
|
|
|
|
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() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent cloud = getPackageManager().getLaunchIntentForPackage(Constants.nc);
|
2018-11-18 13:01:02 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2020-01-17 21:43:42 +01:00
|
|
|
cloud = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.nc));
|
2018-11-18 13:01:02 +01:00
|
|
|
startActivity(cloud);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2020-01-13 03:26:44 +01:00
|
|
|
/*End of Disroot's Dandelion*
|
2018-09-13 16:58:36 +02:00
|
|
|
//Diaspora info
|
|
|
|
private void showDiaInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showDiaDialog(){
|
|
|
|
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() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
}
|
|
|
|
});
|
2018-11-18 13:01:02 +01:00
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
2020-01-13 03:26:44 +01:00
|
|
|
}*/
|
2018-09-13 16:58:36 +02:00
|
|
|
|
2018-09-16 22:00:20 +02:00
|
|
|
private void showForumInfo() {
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-13 03:26:44 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.ForumBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(ForumBtn);
|
2020-01-14 19:17:45 +01:00
|
|
|
BtnPreference.edit().putBoolean( "ForumBtn", false ).apply();
|
2020-01-13 03:26:44 +01:00
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2018-09-20 16:44:19 +02:00
|
|
|
private void showForget() {
|
|
|
|
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() {
|
|
|
|
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
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-13 16:58:36 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-13 03:26:44 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.ChatBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(ChatBtn);
|
2020-01-14 19:17:45 +01:00
|
|
|
BtnPreference.edit().putBoolean( "ChatBtn", false ).apply();
|
2020-01-13 03:26:44 +01:00
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showChatDialog(){
|
|
|
|
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() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent xmpp1 = getPackageManager().getLaunchIntentForPackage(Constants.Conversations);
|
2018-11-18 13:01:02 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2020-01-17 21:43:42 +01:00
|
|
|
xmpp1 = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.Conversations));
|
2018-11-18 13:01:02 +01:00
|
|
|
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() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-14 19:17:45 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.PadBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(PadBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "PadBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-16 22:00:20 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
2018-11-18 13:01:02 +01:00
|
|
|
private void showPAdDialog(){
|
|
|
|
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() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent pad = getPackageManager().getLaunchIntentForPackage(Constants.Padland);
|
2018-11-18 13:01:02 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2020-01-17 21:43:42 +01:00
|
|
|
pad = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.Padland));
|
2018-11-18 13:01:02 +01:00
|
|
|
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() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-14 19:17:45 +01:00
|
|
|
@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();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showBinInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-14 19:17:45 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.BinBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(BinBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "BinBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showUploadInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
findViewById(R.id.dashboard).setVisibility(View.GONE);
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-14 19:17:45 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.UploadBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(UploadBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "UploadBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showSearxInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-13 16:58:36 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-14 19:17:45 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
|
|
|
|
if (findViewById( R.id.SearxBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(SearxBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "SearxBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showPollsInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
builder.setNeutralButton( R.string.hide, new DialogInterface.OnClickListener() {
|
2020-01-15 19:02:03 +01:00
|
|
|
@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;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showBoardInfo() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-16 22:00:20 +02:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
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.BoardBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(BoardBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "BoardBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showCallsInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.CallsTitle);
|
|
|
|
builder.setMessage(getString(R.string.CallsInfo));
|
|
|
|
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_CALLSHELP);
|
|
|
|
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.CallsBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(CallsBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "CallsBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
private void showBoardDialog(){
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.CallsDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
Intent calls = getPackageManager().getLaunchIntentForPackage(Constants.CallsApp);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
calls = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.CallsApp));
|
|
|
|
startActivity(calls);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
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() {
|
|
|
|
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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-12-30 10:52:32 +01:00
|
|
|
}
|
|
|
|
});
|
2020-01-17 21:43:42 +01:00
|
|
|
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.NotesBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(NotesBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "NotesBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-12-18 21:00:58 +01:00
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
private void showNotesDialog(){
|
|
|
|
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() {
|
2020-01-17 21:43:42 +01:00
|
|
|
Intent notes = getPackageManager().getLaunchIntentForPackage(Constants.NotesApp);
|
2018-12-18 21:00:58 +01:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
2020-01-17 21:43:42 +01:00
|
|
|
notes = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.NotesApp));
|
2018-12-18 21:00:58 +01:00
|
|
|
startActivity(notes);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(R.string.global_cancel , null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
2020-01-17 21:43:42 +01:00
|
|
|
private void showGitInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.GitTitle);
|
|
|
|
builder.setMessage(getString(R.string.GitInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.setNegativeButton(R.string.tell_more, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_GITHELP);
|
|
|
|
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.GitBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(GitBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "GitBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
private void showGitDialog(){
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setCancelable(false);
|
|
|
|
builder.setTitle(R.string.DiaInstallTitle);
|
|
|
|
builder.setMessage(getString(R.string.GitsDialog));
|
|
|
|
builder.setPositiveButton(R.string.global_install, new DialogInterface.OnClickListener() {
|
|
|
|
Intent git = getPackageManager().getLaunchIntentForPackage(Constants.GitApp);
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
git = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + Constants.GitApp));
|
|
|
|
startActivity(git);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
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)
|
2020-01-09 19:33:07 +01:00
|
|
|
.setTitle(R.string.UserTitle)
|
|
|
|
.setMessage(getString(R.string.UserInfo))
|
|
|
|
.setPositiveButton(R.string.global_ok, null);
|
2020-01-17 21:43:42 +01:00
|
|
|
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.UserBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(UserBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "UserBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
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);
|
|
|
|
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();
|
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);
|
2020-01-17 21:43:42 +01:00
|
|
|
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.HowToBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(HowToBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "HowToBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
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);
|
2020-01-17 21:43:42 +01:00
|
|
|
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.AboutBtn).getParent()!=null){
|
|
|
|
viewGroup.removeView(AboutBtn);
|
|
|
|
BtnPreference.edit().putBoolean( "AboutBtn", false ).apply();
|
|
|
|
return;}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 16:58:36 +02:00
|
|
|
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()
|
2020-01-09 19:33:07 +01:00
|
|
|
{
|
2018-09-15 02:03:38 +02:00
|
|
|
@Override
|
2020-01-09 19:33:07 +01:00
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
}
|
|
|
|
});
|
2018-09-15 02:03:38 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2020-01-09 19:33:07 +01: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);
|
|
|
|
}
|
|
|
|
|
|
|
|
//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
|
|
|
@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
|
|
|
|
Uri url = getIntent().getData();
|
|
|
|
if (url != null) {
|
|
|
|
Log.d("TAG", "URL Foud");
|
|
|
|
Log.d("TAG", "Url is :" + url);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
2018-09-09 17:41:03 +02:00
|
|
|
webView.loadUrl(url.toString());
|
|
|
|
}
|
|
|
|
//first start
|
|
|
|
if (firstStart.getBoolean("firstrun", true)) {
|
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
|
|
|
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);
|
|
|
|
// To show icons in the actionbar's overflow menu:
|
|
|
|
// http://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar
|
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) {
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.e(Constants.TAG, "onMenuOpened", e);
|
2018-09-22 12:14:39 +02:00
|
|
|
} 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;
|
2020-01-18 20:31:34 +01:00
|
|
|
/*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);
|
2020-01-09 19:33:07 +01:00
|
|
|
hideDashboard();
|
|
|
|
return true;
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
else
|
2020-01-18 20:31:34 +01:00
|
|
|
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;
|
2020-01-13 03:26:44 +01:00
|
|
|
case R.id.action_set_icons:
|
|
|
|
Intent goBtnSettings = new Intent(MainActivity.this, SettingsActivity.class);
|
|
|
|
MainActivity.this.startActivity(goBtnSettings);
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 19:33:07 +01:00
|
|
|
return false;
|
|
|
|
case R.id.action_exit: {
|
|
|
|
moveTaskToBack(true);
|
|
|
|
finish();
|
2018-09-09 17:41:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
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);
|
2020-01-13 03:26:44 +01:00
|
|
|
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
|
|
|
|
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
|
|
|
|
webView.getSettings().setDatabaseEnabled(true);
|
2018-09-02 19:00:45 +02:00
|
|
|
webView.setOnLongClickListener(this);
|
2018-11-06 00:09:41 +01:00
|
|
|
|
|
|
|
//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);
|
|
|
|
}
|
2020-01-13 03:26:44 +01:00
|
|
|
if (Uri.parse( url ).toString().startsWith( "blob" )){
|
|
|
|
webView.loadUrl("");
|
|
|
|
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.URL_DisApp_UPLOAD)));
|
|
|
|
} else {
|
|
|
|
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 );
|
|
|
|
assert dm != null;
|
|
|
|
dm.enqueue( request );
|
|
|
|
}
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
//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());
|
2020-01-09 19:33:07 +01:00
|
|
|
webView.loadUrl(loadUrl);
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
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) {
|
2020-01-13 03:26:44 +01:00
|
|
|
if(url.startsWith("http")&&url.contains("disroot")&&!Uri.parse( url ).toString().startsWith( "blob" )) {
|
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()) {
|
2020-01-17 21:43:42 +01:00
|
|
|
ActivityCompat.requestPermissions(this, listPermissionsNeeded.toArray(new String[listPermissionsNeeded.size()]),Constants.REQUEST_ID_MULTIPLE_PERMISSIONS);
|
|
|
|
Log.e(Constants.TAG, "Returned falseeeee-------");
|
2018-09-13 14:38:45 +02:00
|
|
|
return false;
|
|
|
|
}
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.d(Constants.TAG, "Permission returned trueeeee-------");
|
2018-09-13 14:38:45 +02:00
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2018-09-15 02:03:38 +02:00
|
|
|
public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) {
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.d(Constants.TAG, "Permission callback called-------");
|
2018-09-13 14:38:45 +02:00
|
|
|
switch (requestCode) {
|
2020-01-17 21:43:42 +01:00
|
|
|
case Constants.REQUEST_ID_MULTIPLE_PERMISSIONS: {
|
2018-09-13 14:38:45 +02:00
|
|
|
|
|
|
|
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) {
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.d(Constants.TAG, "camera & Storage permission granted");
|
2018-09-13 14:38:45 +02:00
|
|
|
Toast.makeText(this, "Permissions granted! Try now.", Toast.LENGTH_SHORT).show();
|
2020-01-09 19:33:07 +01:00
|
|
|
//chromClt.openChooser(WebView, chooserPathUri, chooserParams);
|
2018-09-13 14:38:45 +02:00
|
|
|
// process the normal flow
|
|
|
|
//else any one or both the permissions are not granted
|
|
|
|
} else {
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.d(Constants.TAG, "Some permissions are not granted ask again ");
|
2018-09-13 14:38:45 +02:00
|
|
|
//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() {
|
2020-01-09 19:33:07 +01: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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
//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) {
|
2020-01-17 21:43:42 +01:00
|
|
|
if (requestCode != Constants.INPUT_FILE_REQUEST_CODE || mFilePathCallback == null) {
|
2018-09-13 14:38:45 +02:00
|
|
|
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) {
|
2020-01-17 21:43:42 +01:00
|
|
|
if (requestCode != Constants.FILECHOOSER_RESULTCODE || mUploadMessage == null) {
|
2018-09-13 14:38:45 +02:00
|
|
|
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);
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.e(Constants.TAG, "onGeolocationPermissionsShowPrompt: " );
|
2018-09-13 14:38:45 +02:00
|
|
|
callback.invoke(origin, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// For Android 5.0
|
|
|
|
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
|
|
|
|
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
|
2020-01-17 21:43:42 +01:00
|
|
|
Log.e(Constants.TAG, "Unable to create Image File", ex);
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
// 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);
|
2020-01-17 21:43:42 +01:00
|
|
|
startActivityForResult(chooserIntent, Constants.INPUT_FILE_REQUEST_CODE);
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
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);
|
2020-01-17 21:43:42 +01:00
|
|
|
startActivityForResult(chooserIntent, Constants.FILECHOOSER_RESULTCODE);
|
2018-09-13 14:38:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|