Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	fastlane/metadata/android/tr-TR/changelogs/36.txt
  • Loading branch information
deltazefiro committed Jul 5, 2023
2 parents 3d84d83 + c90868a commit 49bd343
Show file tree
Hide file tree
Showing 25 changed files with 724 additions and 109 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: 'gradle'
- name: Build with Gradle
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'
cache: 'gradle'
- name: Inject signing key
run: |
Expand Down
19 changes: 10 additions & 9 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
applicationId "deltazero.amarok"
minSdkVersion 26
targetSdkVersion 33
versionCode 37
versionName "0.8.3b2"
versionCode 50
versionName "0.8.4a1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down Expand Up @@ -89,8 +89,8 @@ android {
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
namespace 'deltazero.amarok'
}
Expand All @@ -100,21 +100,22 @@ repositories {
}

dependencies {
def shizukuVersion = '12.2.0'
def shizukuVersion = '13.1.1'
implementation "dev.rikka.shizuku:api:${shizukuVersion}"
implementation "dev.rikka.shizuku:provider:${shizukuVersion}"

implementation 'com.github.heruoxin.Delegated-Scopes-Manager:client:master-SNAPSHOT'

def appCenterSdkVersion = '5.0.0'
def appCenterSdkVersion = '5.0.1'
appcenterImplementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
appcenterImplementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
appcenterImplementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"

implementation 'com.github.Dimezis:BlurView:version-2.0.3'
implementation 'com.github.getActivity:XXPermissions:16.8'
implementation 'com.github.getActivity:XToast:8.9'
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.github.heruoxin.Delegated-Scopes-Manager:client:master-SNAPSHOT'
implementation 'com.google.android.material:material:1.7.0'
implementation "androidx.biometric:biometric:1.1.0"
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0'
Expand Down

This file was deleted.

66 changes: 47 additions & 19 deletions app/src/main/java/deltazero/amarok/FileHider.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import androidx.annotation.Nullable;

import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.file.FileVisitResult;
Expand All @@ -20,6 +21,7 @@

import deltazero.amarok.utils.FileHiderUtil;

@SuppressWarnings("deprecation")
public class FileHider {
private final static String TAG = "FileHider";

Expand Down Expand Up @@ -124,20 +126,34 @@ private static Path processFilename(Path path, ProcessConfig.ProcessMethod proce
private static void processFileHeader(Path path) {
Log.d(TAG, "Processing file header: " + path);

try (RandomAccessFile file = new RandomAccessFile(path.toFile(), "rw")) {
try {

File file = path.toFile();

// Preserve original lastModified time
var lastModified = path.toFile().lastModified();

byte[] bytes = new byte[8];
int numBytesRead = file.read(bytes);
int numBytesToReplace = Math.max(Math.min(numBytesRead, 8), 0);
try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {

for (int i = 0; i < numBytesToReplace; i++) {
bytes[i] = (byte) ~bytes[i];
byte[] bytes = new byte[8];
int numBytesRead = randomAccessFile.read(bytes);
int numBytesToReplace = Math.max(Math.min(numBytesRead, 8), 0);

for (int i = 0; i < numBytesToReplace; i++) {
bytes[i] = (byte) ~bytes[i];
}

randomAccessFile.seek(0);
randomAccessFile.write(bytes, 0, numBytesToReplace);

} catch (IOException e) {
Log.w(TAG, "processFileHeader failed: ", e);
}

file.seek(0);
file.write(bytes, 0, numBytesToReplace);
// noinspection ResultOfMethodCallIgnored
file.setLastModified(lastModified);

} catch (IOException e) {
} catch (SecurityException e) {
Log.w(TAG, "processFileHeader failed: ", e);
}
}
Expand All @@ -149,23 +165,35 @@ private static void processWholeFile(Path path) {
long numReadLoops = 0;
int numBytesRead, numBytesToReplace;

try (RandomAccessFile file = new RandomAccessFile(path.toFile(), "rw")) {
try {

while ((numBytesRead = file.read(buffer)) != -1) {
File file = path.toFile();

numBytesToReplace = Math.max(Math.min(numBytesRead, buffer.length), 0);
// Preserve original lastModified time
var lastModified = path.toFile().lastModified();

for (int i = 0; i < numBytesToReplace; i++) {
buffer[i] = (byte) ~buffer[i];
}
try (RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {
while ((numBytesRead = randomAccessFile.read(buffer)) != -1) {

file.seek(numReadLoops * buffer.length);
file.write(buffer, 0, numBytesToReplace);
numBytesToReplace = Math.max(Math.min(numBytesRead, buffer.length), 0);

for (int i = 0; i < numBytesToReplace; i++) {
buffer[i] = (byte) ~buffer[i];
}

numReadLoops++;
randomAccessFile.seek(numReadLoops * buffer.length);
randomAccessFile.write(buffer, 0, numBytesToReplace);

numReadLoops++;
}
} catch (IOException e) {
Log.w(TAG, "processWholeFile failed: ", e);
}

} catch (IOException e) {
// noinspection ResultOfMethodCallIgnored
file.setLastModified(lastModified);

} catch (SecurityException e) {
Log.w(TAG, "processWholeFile failed: ", e);
}
}
Expand Down
21 changes: 21 additions & 0 deletions app/src/main/java/deltazero/amarok/PrefMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import android.content.Context;
import android.content.SharedPreferences;

import androidx.annotation.Nullable;

import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -147,4 +149,23 @@ public void setEnablePanicButton(boolean isEnablePanicButton) {
mPrefEditor.putBoolean("enablePanicButton", isEnablePanicButton);
mPrefEditor.apply();
}

@Nullable
public String getAmarokPassword() {
return mPrefs.getString("amarokPassword", null);
}

public void setAmarokPassword(String password) {
mPrefEditor.putString("amarokPassword", password);
mPrefEditor.apply();
}

public boolean getEnableAmarokBiometricAuth() {
return mPrefs.getBoolean("enableAmarokBiometricAuth", false);
}

public void setEnableAmarokBiometricAuth(boolean enableAmarokBiometricAuth) {
mPrefEditor.putBoolean("enableAmarokBiometricAuth", enableAmarokBiometricAuth);
mPrefEditor.apply();
}
}
2 changes: 1 addition & 1 deletion app/src/main/java/deltazero/amarok/QuickHideService.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void updatePanicButton() {

assert isProcessing.getValue() != null;
if (isProcessing.getValue()) {
ivPanicButton.setColorFilter(getApplication().getColor(R.color.design_default_color_error),
ivPanicButton.setColorFilter(getApplication().getColor(com.google.android.material.R.color.design_default_color_error),
android.graphics.PorterDuff.Mode.SRC_IN);
ivPanicButton.setEnabled(false);
} else {
Expand Down
46 changes: 30 additions & 16 deletions app/src/main/java/deltazero/amarok/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import android.content.Intent;
import android.os.Bundle;
import android.service.quicksettings.TileService;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;

Expand All @@ -25,6 +27,7 @@
import deltazero.amarok.R;
import deltazero.amarok.utils.AppCenterUtil;
import deltazero.amarok.utils.PermissionUtil;
import deltazero.amarok.utils.SecurityAuth;

public class MainActivity extends AppCompatActivity {

Expand All @@ -33,6 +36,7 @@ public class MainActivity extends AppCompatActivity {
private Hider hider;
private PrefMgr prefMgr;

private ScrollView svMainLayout;
private ImageView ivStatusImg;
private TextView tvStatusInfo, tvStatus;
private MaterialButton btChangeStatus, btSetHideFiles, btSetHideApps;
Expand All @@ -41,32 +45,42 @@ public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// Init
// Setup activity
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
hider = new Hider(this);
prefMgr = hider.prefMgr;

// Start App-center
AppCenterUtil.startAppCenter(this);

// Link LiveData
isProcessing = hider.getIsProcessingLiveData();
isProcessing.observe(this, aBoolean -> updateUi());
// Prepare data & init hider
hider = new Hider(this);
prefMgr = hider.prefMgr;

// Init UI
svMainLayout = findViewById(R.id.main_sv_main_layout);
ivStatusImg = findViewById(R.id.main_iv_status);
tvStatus = findViewById(R.id.main_tv_status);
tvStatusInfo = findViewById(R.id.main_tv_statusinfo);
btChangeStatus = findViewById(R.id.main_bt_change_status);
btSetHideApps = findViewById(R.id.main_bt_set_hide_apps);
btSetHideFiles = findViewById(R.id.main_bt_set_hide_files);
piProcessStatus = findViewById(R.id.main_pi_process_status);
updateUi();
refreshUi();

// Setup observer
isProcessing = hider.getIsProcessingLiveData();
isProcessing.observe(this, aBoolean -> refreshUi());

// Process Permissions
PermissionUtil.requestStoragePermission(this);
checkAppHiderAvailability();

// Show security check fragment
svMainLayout.setVisibility(View.GONE);
new SecurityAuth(this, succeed -> {
if (succeed) svMainLayout.setVisibility(View.VISIBLE);
else finish();
}).authenticate();
}

public void changeStatus(View view) {
Expand Down Expand Up @@ -114,12 +128,8 @@ public void setHideFile(View view) {
startActivity(new Intent(this, SetHideFilesActivity.class));
}


public void updateUi() {

assert isProcessing.getValue() != null;

if (isProcessing.getValue()) {
public void refreshUi() {
if (isProcessing != null && Boolean.TRUE.equals(isProcessing.getValue())) {
// Processing
piProcessStatus.show();
btChangeStatus.setEnabled(false);
Expand Down Expand Up @@ -149,8 +159,12 @@ public void updateUi() {
}
}

TileService.requestListeningState(MainActivity.this,
new ComponentName(MainActivity.this, QuickSettingService.class));
try {
TileService.requestListeningState(MainActivity.this,
new ComponentName(MainActivity.this, QuickSettingService.class));
} catch (IllegalArgumentException e) {
Log.w(TAG, "QuickSetting is unavailable when running in an Android work profile.");
}
}


Expand All @@ -171,7 +185,7 @@ public void checkAppHiderAvailability() {

@Override
protected void onResume() {
updateUi();
refreshUi();
super.onResume();
}

Expand Down
Loading

0 comments on commit 49bd343

Please sign in to comment.