Commit 9744e246 authored by Massimiliano's avatar Massimiliano
Browse files

added new settings activity to make icons hideble+

Started with new theme+
corrected issue when going back after visibility change
parent 8d22684c
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<option name="values"> <option name="values">
<map> <map>
<entry key="assetSourceType" value="FILE" /> <entry key="assetSourceType" value="FILE" />
<entry key="outputName" value="ic_battery" /> <entry key="outputName" value="ic_app_logo" />
<entry key="sourceFile" value="$PROJECT_DIR$/../DisIcons/battery.svg" /> <entry key="sourceFile" value="$PROJECT_DIR$/../DisIcons/v2/ic_app_logo.svg" />
</map> </map>
</option> </option>
</PersistentState> </PersistentState>
......
...@@ -11,7 +11,7 @@ If you don't have a Disroot account you can still use this app to access all th ...@@ -11,7 +11,7 @@ If you don't have a Disroot account you can still use this app to access all th
* Ethercalc * Ethercalc
* Private bin * Private bin
* Upload * Upload
* Poll * Polls
* Searx * Searx
* Diaspora* (requires a Diaspora only account) * Diaspora* (requires a Diaspora only account)
......
...@@ -6,8 +6,8 @@ android { ...@@ -6,8 +6,8 @@ android {
applicationId "org.disroot.disrootapp" applicationId "org.disroot.disrootapp"
minSdkVersion 15 minSdkVersion 15
targetSdkVersion 28 targetSdkVersion 28
versionCode 22 versionCode 23
versionName "1.2.3" versionName "1.9.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
...@@ -48,3 +48,7 @@ repositories { ...@@ -48,3 +48,7 @@ repositories {
dependencies { dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3' implementation 'com.android.support.constraint:constraint-layout:1.1.3'
} }
dependencies {
implementation 'com.android.support.constraint:constraint-layout:+'
}
...@@ -13,16 +13,17 @@ ...@@ -13,16 +13,17 @@
android:allowBackup="true" android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor" android:fullBackupContent="@xml/backup_descriptor"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:icon="@mipmap/ic_disroot" android:icon="@drawable/ic_app_logo"
android:label="@string/app_name" android:label="@string/app_name"
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/DisTheme"> android:theme="@style/DisTheme">
<receiver <receiver
android:name=".StatusBroadcastReceiver" android:name=".StatusBroadcastReceiver"
android:enabled="true" android:enabled="true"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/> <action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter> </intent-filter>
</receiver> </receiver>
...@@ -45,7 +46,7 @@ ...@@ -45,7 +46,7 @@
android:name=".ui.MainActivity" android:name=".ui.MainActivity"
android:configChanges="orientation|screenSize" android:configChanges="orientation|screenSize"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:label="@string/app_name"> android:label="@string/dashboard">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.VIEW" /> <action android:name="android.intent.action.VIEW" />
...@@ -70,6 +71,10 @@ ...@@ -70,6 +71,10 @@
android:name=".ui.StateMessagesActivity" android:name=".ui.StateMessagesActivity"
android:label="@string/title_activity_state" android:label="@string/title_activity_state"
android:theme="@style/DisTheme" /> android:theme="@style/DisTheme" />
<activity
android:name=".ui.SettingsActivity"
android:label="@string/settings"
android:theme="@style/DisTheme" />
<activity <activity
android:name="wsdfhjxc.taponium.MainActivity" android:name="wsdfhjxc.taponium.MainActivity"
android:label="@string/title_activity_tap" android:label="@string/title_activity_tap"
......
...@@ -80,10 +80,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -80,10 +80,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
SharedPreferences firstStart = null;//first start SharedPreferences firstStart = null;//first start
SharedPreferences check = null; SharedPreferences check = null;
SharedPreferences BtnPreference;
WebChromeClient.FileChooserParams chooserParams; WebChromeClient.FileChooserParams chooserParams;
ValueCallback<Uri[]> chooserPathUri; ValueCallback<Uri[]> chooserPathUri;
Button button; Button button;
private Button MailBtn,CloudBtn,DiasporaBtn,ForumBtn,ChatBtn,PadBtn,CalcBtn,BinBtn,UploadBtn,SearxBtn,PollsBtn,BoardBtn,NotesBtn,UserBtn,StateBtn,HowToBtn,AboutBtn;//all buttons private Button MailBtn,CloudBtn,ForumBtn,ChatBtn,PadBtn,CalcBtn,BinBtn,UploadBtn,SearxBtn,PollsBtn,BoardBtn,NotesBtn,UserBtn,StateBtn,HowToBtn,AboutBtn;//all buttons
private CookieManager cookieManager; private CookieManager cookieManager;
private WebView webView; private WebView webView;
private DisWebChromeClient disWebChromeClient; private DisWebChromeClient disWebChromeClient;
...@@ -107,7 +108,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -107,7 +108,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
private static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;//file upload private static final int REQUEST_ID_MULTIPLE_PERMISSIONS = 1;//file upload
private static final int INPUT_FILE_REQUEST_CODE = 1;//file upload private static final int INPUT_FILE_REQUEST_CODE = 1;//file upload
private static final int FILECHOOSER_RESULTCODE = 1;//file upload private static final int FILECHOOSER_RESULTCODE = 1;//file upload
private static final String TAG = MainActivity.class.getSimpleName(); public static final String TAG = MainActivity.class.getSimpleName();
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
...@@ -120,6 +121,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -120,6 +121,11 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
//settings //settings
firstStart = getSharedPreferences("org.disroot.disrootap", MODE_PRIVATE);//fisrt start firstStart = getSharedPreferences("org.disroot.disrootap", MODE_PRIVATE);//fisrt start
check = getSharedPreferences("org.disroot.disrootapp", MODE_PRIVATE); check = getSharedPreferences("org.disroot.disrootapp", MODE_PRIVATE);
//buttons visiblility preference
BtnPreference = getSharedPreferences( "mailBtnVisibility", Context.MODE_PRIVATE );//mail
BtnPreference = getSharedPreferences( "cloudBtnVisibility", Context.MODE_PRIVATE );//cloud
BtnPreference = getSharedPreferences( "forumBtnVisibility", Context.MODE_PRIVATE );//forum
BtnPreference = getSharedPreferences( "chatBtnVisibility", Context.MODE_PRIVATE );//chat
//Status service //Status service
Intent intent = new Intent( MainActivity.this, StatusService.class); Intent intent = new Intent( MainActivity.this, StatusService.class);
...@@ -187,7 +193,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -187,7 +193,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
// Link the button in activity_main.xml // Link the button in activity_main.xml
MailBtn = findViewById( R.id.MailBtn ); MailBtn = findViewById( R.id.MailBtn );
CloudBtn = findViewById( R.id.CloudBtn ); CloudBtn = findViewById( R.id.CloudBtn );
DiasporaBtn = findViewById( R.id.DiasporaBtn ); //DiasporaBtn = findViewById( R.id.DiasporaBtn );//end of Disroot's Dandelion
ForumBtn = findViewById( R.id.ForumBtn ); ForumBtn = findViewById( R.id.ForumBtn );
ChatBtn = findViewById( R.id.ChatBtn ); ChatBtn = findViewById( R.id.ChatBtn );
PadBtn = findViewById( R.id.PadBtn ); PadBtn = findViewById( R.id.PadBtn );
...@@ -203,10 +209,28 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -203,10 +209,28 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
HowToBtn = findViewById( R.id.HowToBtn ); HowToBtn = findViewById( R.id.HowToBtn );
AboutBtn = findViewById( R.id.AboutBtn ); AboutBtn = findViewById( R.id.AboutBtn );
//get preferences
if (BtnPreference.getBoolean( "mailBtnVisibility", true)==false){
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
viewGroup.removeView(MailBtn);
}
if (BtnPreference.getBoolean( "cloudBtnVisibility", true)==false){
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
viewGroup.removeView(CloudBtn);
}
if (BtnPreference.getBoolean( "forumBtnVisibility", true)==false){
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
viewGroup.removeView(ForumBtn);
}
if (BtnPreference.getBoolean( "chatBtnVisibility", true)==false){
ViewGroup viewGroup =((ViewGroup)findViewById( R.id.StateBtn ).getParent());
viewGroup.removeView(ChatBtn);
}
//Set longclick buttons //Set longclick buttons
MailBtn.setOnLongClickListener( this ); MailBtn.setOnLongClickListener( this );
CloudBtn.setOnLongClickListener( this ); CloudBtn.setOnLongClickListener( this );
DiasporaBtn.setOnLongClickListener( this ); //DiasporaBtn.setOnLongClickListener( this );//end of Disroot's Dandelion
ForumBtn.setOnLongClickListener( this ); ForumBtn.setOnLongClickListener( this );
ChatBtn.setOnLongClickListener( this ); ChatBtn.setOnLongClickListener( this );
PadBtn.setOnLongClickListener( this ); PadBtn.setOnLongClickListener( this );
...@@ -225,7 +249,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -225,7 +249,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
//set clickbuttons //set clickbuttons
MailBtn.setOnClickListener( this ); MailBtn.setOnClickListener( this );
CloudBtn.setOnClickListener( this ); CloudBtn.setOnClickListener( this );
DiasporaBtn.setOnClickListener( this ); //DiasporaBtn.setOnClickListener( this );//end of Disroot's Dandelion
ForumBtn.setOnClickListener( this ); ForumBtn.setOnClickListener( this );
ChatBtn.setOnClickListener( this ); ChatBtn.setOnClickListener( this );
PadBtn.setOnClickListener( this ); PadBtn.setOnClickListener( this );
...@@ -275,14 +299,14 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -275,14 +299,14 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
} }
else startActivity(cloud); else startActivity(cloud);
break; break;
case R.id.DiasporaBtn: /*case R.id.DiasporaBtn: //end ofDisroot's Dandelion
Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora); Intent pod = getPackageManager().getLaunchIntentForPackage(Diaspora);
if(getPackageManager().getLaunchIntentForPackage(Diaspora) == null) { if(getPackageManager().getLaunchIntentForPackage(Diaspora) == null) {
showDiaDialog(); showDiaDialog();
break; break;
} }
else startActivity(pod); else startActivity(pod);
break; break;*/
case R.id.ForumBtn: case R.id.ForumBtn:
webView.loadUrl(Constants.URL_DisApp_FORUM); webView.loadUrl(Constants.URL_DisApp_FORUM);
hideDashboard(); hideDashboard();
...@@ -332,8 +356,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -332,8 +356,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
hideDashboard(); hideDashboard();
break; break;
case R.id.UploadBtn: case R.id.UploadBtn:
//startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.URL_DisApp_UPLOAD)));
//workaround for crashing app
webView.loadUrl(Constants.URL_DisApp_UPLOAD); webView.loadUrl(Constants.URL_DisApp_UPLOAD);
hideDashboard(); hideDashboard();
break; break;
...@@ -388,9 +410,9 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -388,9 +410,9 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
case R.id.CloudBtn: case R.id.CloudBtn:
showCloudInfo(); showCloudInfo();
break; break;
case R.id.DiasporaBtn: /*case R.id.DiasporaBtn://end of Disroot's Dandelion
showDiaInfo(); showDiaInfo();
break; break;*/
case R.id.ForumBtn: case R.id.ForumBtn:
showForumInfo(); showForumInfo();
break; break;
...@@ -448,7 +470,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -448,7 +470,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
dashboard.setVisibility( View.GONE ); dashboard.setVisibility( View.GONE );
} }
//Show xmpp choice //Show chat choice
private void showChoose() { private void showChoose() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(R.string.ChooseChatTitle) builder.setTitle(R.string.ChooseChatTitle)
...@@ -548,6 +570,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -548,6 +570,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
hideDashboard(); hideDashboard();
} }
}); });
builder.setNeutralButton( R.string.remove , new DialogInterface.OnClickListener() {
@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);
BtnPreference.edit().putBoolean( "mailBtnVisibility", false ).apply();
return;}
}
});
builder.show(); builder.show();
} }
private void showMailDialog(){ private void showMailDialog(){
...@@ -581,6 +613,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -581,6 +613,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
hideDashboard(); hideDashboard();
} }
}); });
builder.setNeutralButton( R.string.remove , new DialogInterface.OnClickListener() {
@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);
BtnPreference.edit().putBoolean( "cloudBtnVisibility", false ).apply();
return;}
}
});
builder.show(); builder.show();
} }
private void showCloudDialog(){ private void showCloudDialog(){
...@@ -600,6 +642,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -600,6 +642,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
builder.show(); builder.show();
} }
/*End of Disroot's Dandelion*
//Diaspora info //Diaspora info
private void showDiaInfo() { private void showDiaInfo() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
...@@ -631,7 +674,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -631,7 +674,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
}); });
builder.setNegativeButton(R.string.global_cancel , null); builder.setNegativeButton(R.string.global_cancel , null);
builder.show(); builder.show();
} }*/
private void showForumInfo() { private void showForumInfo() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this); AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
...@@ -646,6 +689,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -646,6 +689,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
hideDashboard(); hideDashboard();
} }
}); });
builder.setNeutralButton( R.string.remove , new DialogInterface.OnClickListener() {
@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);
BtnPreference.edit().putBoolean( "forumBtnVisibility", false ).apply();
return;}
}
});
builder.show(); builder.show();
} }
...@@ -674,7 +727,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -674,7 +727,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
builder.setCancelable(false); builder.setCancelable(false);
builder.setTitle(R.string.ChatTitle); builder.setTitle(R.string.ChatTitle);
builder.setMessage(getString(R.string.ChatInfo)); builder.setMessage(getString(R.string.ChatInfo));
// ||check.getBoolean("checkPix", true)==true
if(check.getBoolean("checkConv", true)|| check.getBoolean("checkPix",true)) { if(check.getBoolean("checkConv", true)|| check.getBoolean("checkPix",true)) {
View view = View.inflate(this, R.layout.check_forget, null); View view = View.inflate(this, R.layout.check_forget, null);
final CheckBox forgetChat = (CheckBox) view.findViewById(R.id.forgetChat); final CheckBox forgetChat = (CheckBox) view.findViewById(R.id.forgetChat);
...@@ -695,6 +747,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -695,6 +747,16 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
hideDashboard(); hideDashboard();
} }
}); });
builder.setNeutralButton( R.string.remove , new DialogInterface.OnClickListener() {
@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);
BtnPreference.edit().putBoolean( "chatBtnVisibility", false ).apply();
return;}
}
});
builder.show(); builder.show();
} }
private void showChatDialog(){ private void showChatDialog(){
...@@ -1100,8 +1162,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -1100,8 +1162,6 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
// Inflate the menu items for use in the action bar // Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater(); MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu); inflater.inflate(R.menu.menu_main, menu);
// To show icons in the actionbar's overflow menu: // To show icons in the actionbar's overflow menu:
// http://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar // http://stackoverflow.com/questions/18374183/how-to-show-icons-in-overflow-menu-in-actionbar
if(menu.getClass().getSimpleName().equals("MenuBuilder")) try { if(menu.getClass().getSimpleName().equals("MenuBuilder")) try {
...@@ -1164,6 +1224,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -1164,6 +1224,10 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
Intent goAbout = new Intent(MainActivity.this, AboutActivity.class); Intent goAbout = new Intent(MainActivity.this, AboutActivity.class);
MainActivity.this.startActivity(goAbout); MainActivity.this.startActivity(goAbout);
return true; return true;
case R.id.action_set_icons:
Intent goBtnSettings = new Intent(MainActivity.this, SettingsActivity.class);
MainActivity.this.startActivity(goBtnSettings);
return true;
case R.id.action_clear_cookies: { case R.id.action_clear_cookies: {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){ if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
CookieManager.getInstance().removeAllCookies(null); CookieManager.getInstance().removeAllCookies(null);
...@@ -1198,6 +1262,9 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -1198,6 +1262,9 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
webView.getSettings().setUseWideViewPort(true); webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH); webView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
webView.getSettings().setAllowContentAccess(true); webView.getSettings().setAllowContentAccess(true);
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webView.getSettings().setDatabaseEnabled(true);
webView.setOnLongClickListener(this); webView.setOnLongClickListener(this);
//enable cookies //enable cookies
...@@ -1238,15 +1305,20 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -1238,15 +1305,20 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
Log.e("Permission error","You have asked for permission"); Log.e("Permission error","You have asked for permission");
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
} }
final String filename= URLUtil.guessFileName(url, contentDisposition, mimetype); if (Uri.parse( url ).toString().startsWith( "blob" )){
DownloadManager.Request request = new DownloadManager.Request( webView.loadUrl("");
Uri.parse(url)); startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Constants.URL_DisApp_UPLOAD)));
request.allowScanningByMediaScanner(); } else {
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); final String filename = URLUtil.guessFileName( url, contentDisposition, mimetype );
request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); DownloadManager.Request request = new DownloadManager.Request(
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); Uri.parse( url ) );
assert dm != null; request.allowScanningByMediaScanner();
dm.enqueue(request); 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 );
}
} }
}); });
...@@ -1273,7 +1345,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL ...@@ -1273,7 +1345,7 @@ public class MainActivity extends AppCompatActivity implements View.OnLongClickL
} }
@Override @Override
public boolean shouldOverrideUrlLoading(WebView view, String url) { public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.startsWith("https")|url.startsWith("http")&&url.contains("disroot")) {//&!url.contains("upload.disroot.org") if(url.startsWith("http")&&url.contains("disroot")&&!Uri.parse( url ).toString().startsWith( "blob" )) {
view.loadUrl(url); view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url); return super.shouldOverrideUrlLoading(view, url);
} }
......
package org.disroot.disrootapp.ui;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import org.disroot.disrootapp.R;
public class SettingsActivity extends AppCompatActivity {
SharedPreferences BtnPreference;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate( R.menu.menu_about, menu );
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_home) {
Intent goHome = new Intent( SettingsActivity.this, MainActivity.class );
SettingsActivity.this.startActivity( goHome );
return true;
}
return super.onOptionsItemSelected( item );
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_settings );
Toolbar toolbar = findViewById( R.id.toolbar );
setSupportActionBar( toolbar );
toolbar.setNavigationIcon( R.drawable.ic_arrow_back );
toolbar.setNavigationOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
} );
////buttons visiblility preference list
BtnPreference = getSharedPreferences( "mailBtnVisibility", Context.MODE_PRIVATE );//mail
BtnPreference = getSharedPreferences( "cloudBtnVisibility", Context.MODE_PRIVATE );//cloud
BtnPreference = getSharedPreferences( "forumBtnVisibility", Context.MODE_PRIVATE );//forum
BtnPreference = getSharedPreferences( "chatBtnVisibility", Context.MODE_PRIVATE );//chat
//checkboxlist
checkPrefBox();
}
//Visibility preference functions
public void checkPrefBox() {
//define checkBoxes
View iconSettings =findViewById( R.id.iconSettings );
final CheckBox checkMailBtn = iconSettings.findViewById( R.id.mailBtnPreference );//mail
final CheckBox checkCloudBtn = iconSettings.findViewById( R.id.cloudBtnPreference );//cloud