2018-09-02 19:00:45 +02:00
|
|
|
package org.disroot.disrootapp.ui;
|
|
|
|
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.pm.PackageManager;
|
2018-09-07 20:22:31 +02:00
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
|
import android.support.v7.widget.Toolbar;
|
2018-09-07 20:22:31 +02:00
|
|
|
import android.util.DisplayMetrics;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.util.Log;
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2018-09-08 03:39:01 +02:00
|
|
|
import android.view.animation.TranslateAnimation;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.webkit.WebView;
|
2018-09-07 20:22:31 +02:00
|
|
|
import android.widget.Button;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.widget.FrameLayout;
|
2018-09-07 20:22:31 +02:00
|
|
|
import android.widget.RelativeLayout;
|
2018-09-08 03:39:01 +02:00
|
|
|
import android.widget.ScrollView;
|
2018-09-02 19:00:45 +02:00
|
|
|
import android.widget.TextView;
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
import com.example.webview.R;
|
|
|
|
|
2018-09-07 20:22:31 +02:00
|
|
|
import org.disroot.disrootapp.AboutActivity;
|
2018-09-02 19:00:45 +02:00
|
|
|
import org.disroot.disrootapp.utils.Constants;
|
|
|
|
import org.disroot.disrootapp.utils.DeviceProvider;
|
|
|
|
import org.disroot.disrootapp.webviews.DisWebChromeClient;
|
|
|
|
import org.disroot.disrootapp.webviews.DisWebViewClient;
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
|
|
|
public class MainActivity extends AppCompatActivity implements View.OnLongClickListener {
|
|
|
|
|
|
|
|
private static final String TAG = MainActivity.class.getSimpleName();
|
|
|
|
private WebView webView;
|
|
|
|
private DisWebChromeClient disWebChromeClient;
|
2018-09-07 20:22:31 +02:00
|
|
|
Button button;
|
2018-09-02 19:00:45 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.activity_main);
|
|
|
|
FrameLayout frameLayoutContainer = (FrameLayout) findViewById(R.id.framelayout_container);
|
|
|
|
ViewGroup viewLoading = (ViewGroup) findViewById(R.id.linearlayout_view_loading_container);
|
|
|
|
setupWebView(savedInstanceState, frameLayoutContainer, viewLoading);
|
|
|
|
// enables the activity icon as a 'home' button. required if "android:targetSdkVersion" > 14
|
|
|
|
//getActionBar().setHomeButtonEnabled(true);
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
|
setSupportActionBar(toolbar);
|
|
|
|
final ScrollView dashboard = (ScrollView)findViewById(R.id.dashboard);
|
2018-09-07 20:22:31 +02:00
|
|
|
|
|
|
|
//Set buttons
|
|
|
|
// Locate the button in activity_main.xml
|
2018-09-08 03:39:01 +02:00
|
|
|
button = (Button) findViewById(R.id.MailBtn);//MailBtn
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showMailInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// Capture button clicks
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
// Start NewActivity.class
|
|
|
|
String k9 = "com.fsck.k9";
|
|
|
|
Intent mail = getPackageManager().getLaunchIntentForPackage(k9);
|
|
|
|
if(mail == null) {
|
|
|
|
mail = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+k9));
|
|
|
|
}
|
|
|
|
startActivity(mail);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2018-09-08 03:39:01 +02:00
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.CloudBtn);//CloudBtn
|
|
|
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View v) {
|
|
|
|
showCloudInfo();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
});
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-08 03:39:01 +02:00
|
|
|
String nc = "com.nextcloud.client";
|
|
|
|
Intent cloud = getPackageManager().getLaunchIntentForPackage(nc);
|
|
|
|
if(cloud == null) {
|
|
|
|
cloud = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+nc));
|
|
|
|
}
|
|
|
|
startActivity(cloud);
|
|
|
|
}
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.DiasporaBtn);//DiasporaBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-07 20:22:31 +02:00
|
|
|
String Diaspora = "com.github.dfa.diaspora_android";
|
|
|
|
Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora);
|
|
|
|
if(pod == null) {
|
|
|
|
pod = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+Diaspora));
|
|
|
|
}
|
|
|
|
startActivity(pod);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
button = (Button) findViewById(R.id.ForumBtn);//ForumBtn
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_FORUM);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.ChatBtn);//ChatBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
String Conversations = "eu.siacs.conversations";
|
|
|
|
Intent xmpp = getPackageManager().getLaunchIntentForPackage(Conversations);
|
|
|
|
if(xmpp == null) {
|
|
|
|
xmpp = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+Conversations));
|
|
|
|
}
|
|
|
|
startActivity(xmpp);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.PadBtn);//PadBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
String Padland = "com.mikifus.padland";
|
|
|
|
Intent pad = getPackageManager().getLaunchIntentForPackage(Padland);
|
|
|
|
if(pad == null) {
|
|
|
|
pad = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+Padland));
|
|
|
|
}
|
|
|
|
startActivity(pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.CalcBtn);//CalcBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_CALC);
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
button = (Button) findViewById(R.id.BinBtn);//BinBtn
|
2018-09-07 20:22:31 +02:00
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.loadUrl(Constants.URL_DisApp_BIN);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
2018-09-07 20:22:31 +02:00
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.UploadBtn);//UploadBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_UPLOAD);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.SearxBtn);//SearxBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_SEARX);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.PollsBtn);//PollsBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_POLL);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.BoardBtn);//BoardBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_BOARD);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.UserBtn);//UserBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_USER);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.StateBtn);//UserBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_STATE);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
button = (Button) findViewById(R.id.AboudBtn);//AboutBtn
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
public void onClick(View arg0) {
|
2018-09-07 20:22:31 +02:00
|
|
|
Intent goAbout = new Intent(MainActivity.this, AboutActivity.class);
|
|
|
|
MainActivity.this.startActivity(goAbout);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
2018-09-08 03:39:01 +02:00
|
|
|
private void showCloudInfo() {
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
|
|
|
builder.setTitle(R.string.MailInfoTitle);
|
|
|
|
//builder.setMessage(getString(R.string.activity_main_manteiners, DeviceProvider.getAppVersion(this)));
|
|
|
|
builder.setMessage(getString(R.string.MailInfo));
|
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
|
|
|
@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);
|
|
|
|
}
|
|
|
|
|
|
|
|
@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
|
|
|
|
//if(featureId == Window.FEATURE_ACTION_BAR && menu != null){
|
|
|
|
if(menu.getClass().getSimpleName().equals("MenuBuilder")){
|
|
|
|
try{
|
|
|
|
Method m = menu.getClass().getDeclaredMethod(
|
|
|
|
"setOptionalIconsVisible", Boolean.TYPE);
|
|
|
|
m.setAccessible(true);
|
|
|
|
m.invoke(menu, true);
|
|
|
|
}
|
|
|
|
catch(NoSuchMethodException e){
|
|
|
|
Log.e(TAG, "onMenuOpened", e);
|
|
|
|
}
|
|
|
|
catch(Exception e){
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
return super.onCreateOptionsMenu(menu);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
2018-09-08 03:39:01 +02:00
|
|
|
ScrollView dashboard = (ScrollView)findViewById(R.id.dashboard);
|
|
|
|
TranslateAnimation animateup = new TranslateAnimation(0,0,-2*dashboard.getHeight(),0);
|
|
|
|
TranslateAnimation animatedown = new TranslateAnimation(0,0,0,-dashboard.getHeight());
|
2018-09-02 19:00:45 +02:00
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.action_share:
|
|
|
|
shareCurrentPage();
|
|
|
|
return true;
|
|
|
|
case R.id.action_home:
|
2018-09-08 03:39:01 +02:00
|
|
|
if(webView.getVisibility()==View.VISIBLE){
|
|
|
|
//animation
|
|
|
|
animateup.setDuration(500);
|
|
|
|
animateup.setFillAfter(false);
|
|
|
|
dashboard.startAnimation(animateup);
|
|
|
|
dashboard.setVisibility(View.VISIBLE);
|
|
|
|
webView.setVisibility(View.GONE);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (webView.getVisibility()==View.GONE && webView.getUrl()!=null){
|
|
|
|
//animation
|
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(false);
|
|
|
|
dashboard.startAnimation(animatedown);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
2018-09-08 03:39:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
return true;
|
|
|
|
/**
|
2018-09-02 19:00:45 +02:00
|
|
|
case R.id.action_mail:
|
|
|
|
String k9 = "com.fsck.k9";
|
|
|
|
Intent mail = getPackageManager().getLaunchIntentForPackage(k9);
|
|
|
|
if(mail == null) {
|
|
|
|
mail = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+k9));
|
|
|
|
}
|
|
|
|
startActivity(mail);
|
|
|
|
return true;
|
|
|
|
case R.id.action_cloud:
|
|
|
|
String nc = "com.nextcloud.client";
|
|
|
|
Intent cloud = getPackageManager().getLaunchIntentForPackage(nc);
|
|
|
|
if(cloud == null) {
|
|
|
|
cloud = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+nc));
|
|
|
|
}
|
|
|
|
startActivity(cloud);
|
|
|
|
return true;
|
|
|
|
case R.id.action_diaspora:
|
|
|
|
String Diaspora = "com.github.dfa.diaspora_android";
|
|
|
|
Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora);
|
|
|
|
if(pod == null) {
|
|
|
|
pod = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+Diaspora));
|
|
|
|
}
|
|
|
|
startActivity(pod);
|
|
|
|
return true;
|
|
|
|
case R.id.action_forum:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_FORUM);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_chat:
|
2018-09-04 20:37:11 +02:00
|
|
|
String Conversations = "eu.siacs.conversations";
|
|
|
|
Intent xmpp = getPackageManager().getLaunchIntentForPackage(Conversations);
|
|
|
|
if(xmpp == null) {
|
|
|
|
xmpp = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+Conversations));
|
|
|
|
}
|
2018-09-02 19:00:45 +02:00
|
|
|
startActivity(xmpp);
|
|
|
|
return true;
|
|
|
|
case R.id.action_pad:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_PAD);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_calc:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_CALC);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_bin:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_BIN);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_upload:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_UPLOAD);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_searx:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_SEARX);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_poll:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_POLL);
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_board:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_BOARD);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
|
|
|
case R.id.action_user:
|
|
|
|
webView.loadUrl(Constants.URL_DisApp_USER);
|
2018-09-08 03:39:01 +02:00
|
|
|
animatedown.setDuration(500);
|
|
|
|
animatedown.setFillAfter(true);
|
|
|
|
dashboard.startAnimation(animatedown);
|
2018-09-07 20:22:31 +02:00
|
|
|
dashboard.setVisibility(View.GONE);
|
2018-09-08 03:39:01 +02:00
|
|
|
webView.setVisibility(View.VISIBLE);
|
2018-09-02 19:00:45 +02:00
|
|
|
return true;
|
2018-09-08 03:39:01 +02:00
|
|
|
**/
|
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;
|
|
|
|
default:
|
|
|
|
return super.onOptionsItemSelected(item);
|
|
|
|
}
|
|
|
|
}
|
2018-09-08 03:39:01 +02:00
|
|
|
/**
|
|
|
|
* public void setupToolbar() {
|
|
|
|
* Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
|
|
|
* ((TextView) toolbar.findViewById(R.id.textview_toolbar_title)).setText(R.string.app_name);
|
|
|
|
* setSupportActionBar(toolbar);
|
|
|
|
* ActionBar actionBar = getSupportActionBar();
|
|
|
|
* if (actionBar != null)
|
|
|
|
* actionBar.setTitle("");
|
|
|
|
}*/
|
2018-09-02 19:00:45 +02:00
|
|
|
private void setupWebView(Bundle savedInstanceState, FrameLayout customViewContainer, ViewGroup viewLoading) {
|
|
|
|
disWebChromeClient = new DisWebChromeClient(this, webView, customViewContainer);
|
|
|
|
webView = (WebView) findViewById(R.id.webView_content);
|
|
|
|
webView.setWebViewClient(new DisWebViewClient(savedInstanceState, viewLoading));
|
|
|
|
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-07 20:22:31 +02:00
|
|
|
// webView.loadUrl(Constants.URL_DisApp_MAIN_PAGE);
|
2018-09-02 19:00:45 +02:00
|
|
|
webView.setOnLongClickListener(this);
|
2018-09-07 20:22:31 +02:00
|
|
|
webView.setVisibility(View.GONE);
|
2018-09-02 19:00:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void shareCurrentPage() {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
|
|
|
intent.setAction(Intent.ACTION_SEND);
|
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, webView.getUrl());
|
|
|
|
intent.setType("text/plain");
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2018-09-07 20:22:31 +02:00
|
|
|
private void showMailInfo() {
|
2018-09-02 19:00:45 +02:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
|
2018-09-07 20:22:31 +02:00
|
|
|
builder.setTitle(R.string.MailInfoTitle);
|
|
|
|
//builder.setMessage(getString(R.string.activity_main_manteiners, DeviceProvider.getAppVersion(this)));
|
|
|
|
builder.setMessage(getString(R.string.MailInfo));
|
2018-09-02 19:00:45 +02:00
|
|
|
builder.setPositiveButton(R.string.global_ok, null);
|
|
|
|
builder.show();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onLongClick(View view) {
|
|
|
|
Toast.makeText(view.getContext(), R.string.activity_main_share_info, Toast.LENGTH_LONG).show();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|