Skip to content

Commit

Permalink
Merge branch 'master' into bowiechen/issue1717
Browse files Browse the repository at this point in the history
  • Loading branch information
bowiechen authored Nov 25, 2019
2 parents 1695b19 + e6b58d2 commit 8a99dca
Show file tree
Hide file tree
Showing 144 changed files with 4,316 additions and 3,472 deletions.
33 changes: 33 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Smartphone (please complete the following information):**
- Device: [e.g. Google Pixel 2]
- OS: [e.g. Android 9]
- Rooted: [e.g. No]
- Version: [e.g. 3.3.4]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ See our [Privacy Policy](https://github.com/TeamAmaze/AmazeFileManager/wiki/Priv
Translators
----
Want to help translate Amaze to your language?
Find the folder `values-` for your language [here](https://github.com/TeamAmaze/AmazeFileManager/tree/master/app/src/main/res), and edit the `strings.xml` inside, add the [xml elements](https://www.w3schools.com/xml/xml_syntax.asp) from [here](https://github.com/TeamAmaze/AmazeFileManager/blob/master/app/src/main/res/values/strings.xml) and translate the text inside.

[Transifex translation method](https://www.transifex.com/amaze/amaze-file-manager-1/) is on pause, _maintainer required!_
See [Transifex translation](https://www.transifex.com/amaze/amaze-file-manager/).

Vendors/Developers
----
Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ dependencies {
// https://mvnrepository.com/artifact/org.apache.ftpserver/ftpserver-core
implementation group: 'org.apache.ftpserver', name: 'ftpserver-core', version: '1.1.0'

//implementation 'com.jcraft:jsch:0.1.53'
implementation 'org.greenrobot:eventbus:3.1.1'

implementation 'com.android.volley:volley:1.1.1'

implementation 'eu.chainfire:libsuperuser:1.0.0.+'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.amaze.filemanager.asynchronous.services.ftp;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;

import android.content.Context;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.*;

/**
* This test is separated from FtpServiceEspressoTest since it does not actually requires the FTP
* service itself.
Expand All @@ -35,12 +36,12 @@ public void testGetLocalInetAddressMustNotBeEmpty(){
/**
* To test IP address returned by {@link FtpService#getLocalInetAddress(Context)} must be 192.168.43.1.
*
* <b>Remember to turn on wifi AP when running this test on <u>real</u> devices.</b>
* <b>Remember to turn on Wi-Fi AP when running this test on <u>real</u> devices.</b>
*/
@Test
public void testGetLocalInetAddressMustBeAPAddress(){
if(!FtpService.isEnabledWifiHotspot(InstrumentationRegistry.getTargetContext()))
fail("Please enable wifi hotspot on your device to run this test!");
fail("Please enable Wi-Fi hotspot on your device to run this test!");

assertEquals("192.168.43.1", FtpService.getLocalInetAddress(InstrumentationRegistry.getTargetContext()).getHostAddress());
}
Expand Down
20 changes: 11 additions & 9 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />

<uses-feature
android:name="android.hardware.touchscreen"
Expand Down Expand Up @@ -206,15 +207,6 @@
</intent-filter>
</receiver>

<receiver
android:name="com.amaze.filemanager.ui.notifications.FtpNotification"
android:exported="true">
<intent-filter>
<action android:name="com.amaze.filemanager.services.ftpservice.FTPReceiver.FTPSERVER_STARTED" />
<action android:name="com.amaze.filemanager.services.ftpservice.FTPReceiver.FTPSERVER_STOPPED" />
</intent-filter>
</receiver>

<provider
android:authorities="${applicationId}.FILE_PROVIDER"
android:name=".utils.GenericFileProvider"
Expand All @@ -225,6 +217,16 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths"/>
</provider>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.amaze.filemanager"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ public void exit() {
}
} else {
this.backPressedToExitOnce = true;
showToast(getString(R.string.pressagain));
showToast(getString(R.string.press_again));
new Handler().postDelayed(() -> {
backPressedToExitOnce = false;
}, 2000);
Expand Down Expand Up @@ -947,7 +947,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
break;
}
final MaterialDialog dialog = GeneralDialogCreation.showBasicDialog(mainActivity,
R.string.questionset, R.string.setashome, R.string.yes, R.string.no);
R.string.question_set_path_as_home, R.string.set_as_home, R.string.yes, R.string.no);
dialog.getActionButton(DialogAction.POSITIVE).setOnClickListener((v) -> {
main.home = main.getCurrentPath();
updatePaths(main.no);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ public void selectItem(int item) {
loadPrefFragment(new ColorPref(), R.string.color_title);
break;
case FOLDERS_PREFERENCE:
loadPrefFragment(new FoldersPref(), R.string.sidebarfolders_title);
loadPrefFragment(new FoldersPref(), R.string.sidebar_folders_title);
break;
case QUICKACCESS_PREFERENCE:
loadPrefFragment(new QuickAccessPref(), R.string.sidebarquickaccess_title);
loadPrefFragment(new QuickAccessPref(), R.string.sidebar_quick_access_title);
break;
case ADVANCEDSEARCH_PREFERENCE:
loadPrefFragment(new AdvancedSearchPref(), R.string.advanced_search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ protected void onSaveInstanceState(Bundle outState) {
private void checkUnsavedChanges() {
if (mOriginal != null && mInput.isShown() && !mOriginal.equals(mInput.getText().toString())) {
new MaterialDialog.Builder(this)
.title(R.string.unsavedchanges)
.content(R.string.unsavedchangesdesc)
.title(R.string.unsaved_changes)
.content(R.string.unsaved_changes_description)
.positiveText(R.string.yes)
.negativeText(R.string.no)
.positiveColor(getAccent())
Expand Down Expand Up @@ -274,7 +274,7 @@ private void saveFile(final String editTextString) {
Toast.makeText(getApplicationContext(), R.string.error_io, Toast.LENGTH_SHORT).show();
break;
case WriteFileAbstraction.EXCEPTION_SHELL_NOT_RUNNING:
Toast.makeText(getApplicationContext(), R.string.rootfailure, Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), R.string.root_failure, Toast.LENGTH_SHORT).show();
break;
}
}).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public void onBindViewHolder(final RecyclerView.ViewHolder vholder, int p) {
if (p == getItemCount() - 1) {
holder.rl.setMinimumHeight((int) minRowHeight);
if (itemsDigested.size() == (getBoolean(PREFERENCE_SHOW_GOBACK_BUTTON)? 1:0))
holder.txtTitle.setText(R.string.nofiles);
holder.txtTitle.setText(R.string.no_files);
else {
holder.txtTitle.setText("");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void finalizeNotification(ArrayList<HybridFile> failedOps, boolean move) {

if(failedOps.size()==0)return;
NotificationCompat.Builder mBuilder=new NotificationCompat.Builder(getApplicationContext(), NotificationConstants.CHANNEL_NORMAL_ID);
mBuilder.setContentTitle(getString(R.string.operationunsuccesful));
mBuilder.setContentTitle(getString(R.string.operation_unsuccesful));

mBuilder.setContentText(getString(R.string.copy_error, getString(getTitle(move)).toLowerCase()));
mBuilder.setAutoCancel(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* Created by yashwanthreddyg on 09-06-2016.
*
* Edited by zent-co on 30-07-2019
* Edited by bowiechen on 2019-10-19.
*/

import android.app.AlarmManager;
Expand All @@ -42,26 +43,13 @@
import android.os.IBinder;
import android.os.SystemClock;
import android.preference.PreferenceManager;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.widget.Toast;

import com.amaze.filemanager.R;
import com.amaze.filemanager.ui.notifications.FtpNotification;
import com.amaze.filemanager.ui.notifications.NotificationConstants;
import com.amaze.filemanager.utils.files.CryptUtil;

import org.apache.ftpserver.ConnectionConfigFactory;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.Authority;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.ssl.ClientAuth;
import org.apache.ftpserver.ssl.impl.DefaultSslConfiguration;
import org.apache.ftpserver.usermanager.impl.BaseUser;
import org.apache.ftpserver.usermanager.impl.WritePermission;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
Expand All @@ -75,16 +63,26 @@
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;

import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory;
import org.apache.ftpserver.ConnectionConfigFactory;
import org.apache.ftpserver.FtpServer;
import org.apache.ftpserver.FtpServerFactory;
import org.apache.ftpserver.ftplet.Authority;
import org.apache.ftpserver.ftplet.FtpException;
import org.apache.ftpserver.listener.ListenerFactory;
import org.apache.ftpserver.ssl.ClientAuth;
import org.apache.ftpserver.ssl.impl.DefaultSslConfiguration;
import org.apache.ftpserver.usermanager.impl.BaseUser;
import org.apache.ftpserver.usermanager.impl.WritePermission;
import org.greenrobot.eventbus.EventBus;

public class FtpService extends Service implements Runnable {

public static final int DEFAULT_PORT = 2211;
public static final String DEFAULT_USERNAME = "";
public static final int DEFAULT_TIMEOUT = 600; // default timeout, in sec
public static final boolean DEFAULT_SECURE = false;
public static final boolean DEFAULT_SECURE = true;
public static final String PORT_PREFERENCE_KEY = "ftpPort";
public static final String KEY_PREFERENCE_PATH = "ftp_path";
public static final String KEY_PREFERENCE_USERNAME = "ftp_username";
Expand All @@ -95,13 +93,16 @@ public class FtpService extends Service implements Runnable {
public static final String INITIALS_HOST_FTP = "ftp://";
public static final String INITIALS_HOST_SFTP = "ftps://";

private static final String WIFI_AP_ADDRESS = "192.168.43.1";
private static final String WIFI_AP_ADDRESS_PREFIX = "192.168.43.";
private static final char[] KEYSTORE_PASSWORD = "vishal007".toCharArray();

// Service will (global) broadcast when server start/stop
static public final String ACTION_STARTED = "com.amaze.filemanager.services.ftpservice.FTPReceiver.FTPSERVER_STARTED";
static public final String ACTION_STOPPED = "com.amaze.filemanager.services.ftpservice.FTPReceiver.FTPSERVER_STOPPED";
static public final String ACTION_FAILEDTOSTART = "com.amaze.filemanager.services.ftpservice.FTPReceiver.FTPSERVER_FAILEDTOSTART";
// Service will broadcast via event bus when server start/stop
public enum FtpReceiverActions {
STARTED,
STARTED_FROM_TILE,
STOPPED,
FAILED_TO_START
}

// RequestStartStopReceiver listens for these actions to start/stop this server
static public final String ACTION_START_FTPSERVER = "com.amaze.filemanager.services.ftpservice.FTPReceiver.ACTION_START_FTPSERVER";
Expand Down Expand Up @@ -223,10 +224,9 @@ public void run() {
try {
server = serverFactory.createServer();
server.start();

sendBroadcast(new Intent(FtpService.ACTION_STARTED).setPackage(getPackageName()).putExtra(TAG_STARTED_BY_TILE, isStartedByTile));
EventBus.getDefault().post(isStartedByTile ? FtpReceiverActions.STARTED_FROM_TILE : FtpReceiverActions.STARTED);
} catch (Exception e) {
sendBroadcast(new Intent(FtpService.ACTION_FAILEDTOSTART).setPackage(getPackageName()));
EventBus.getDefault().post(FtpReceiverActions.FAILED_TO_START);
}
}

Expand All @@ -245,7 +245,7 @@ public void onDestroy() {
}
if (server != null) {
server.stop();
sendBroadcast(new Intent(FtpService.ACTION_STOPPED).setPackage(getPackageName()));
EventBus.getDefault().post(FtpReceiverActions.STOPPED);
}
}

Expand Down Expand Up @@ -323,8 +323,11 @@ public static InetAddress getLocalInetAddress(Context context) {
Enumeration<InetAddress> addresses = netinterface.getInetAddresses();
while (addresses.hasMoreElements()) {
InetAddress address = addresses.nextElement();
if (address == null) {
continue;
}

if(WIFI_AP_ADDRESS.equals(address.getHostAddress()) && isEnabledWifiHotspot(context))
if(address.getHostAddress().startsWith(WIFI_AP_ADDRESS_PREFIX) && isEnabledWifiHotspot(context))
return address;

// this is the condition that sometimes gives problems
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,32 @@

import com.amaze.filemanager.R;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;

/**
* Created by vishal on 1/1/17.
*/

@TargetApi(Build.VERSION_CODES.N)
public class FtpTileService extends TileService {
private BroadcastReceiver ftpReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateTileState();
}
};

@Subscribe
public void onFtpReceiverActions(FtpService.FtpReceiverActions signal) {
updateTileState();
}

@Override
public void onStartListening() {
super.onStartListening();

IntentFilter f = new IntentFilter();
f.addAction(FtpService.ACTION_STARTED);
f.addAction(FtpService.ACTION_STOPPED);
registerReceiver(ftpReceiver, f);
EventBus.getDefault().register(this);
updateTileState();
}

@Override
public void onStopListening() {
super.onStopListening();

unregisterReceiver(ftpReceiver);
EventBus.getDefault().unregister(this);
}

@Override
Expand Down
Loading

0 comments on commit 8a99dca

Please sign in to comment.