Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pixel7 pro support #107

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 31
namespace 'eu.chainfire.holeylight'
signingConfigs {
debug {
storeFile file('C:\\Users\\Fissy\\Desktop\\apktool\\tools\\keystore\\Retail.jks')
storePassword 'Qpalzm1784!'
keyAlias 'Retail'
keyPassword 'Qpalzm1784!'
}
}
compileSdk 33
defaultConfig {
applicationId "eu.chainfire.holeylight"
minSdkVersion 28
targetSdkVersion 31
targetSdk 33
versionCode 102
versionName "1.02"
signingConfig signingConfigs.debug
}
buildTypes {
release {
Expand Down Expand Up @@ -39,31 +49,30 @@ android {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.3.0-beta01'
implementation 'androidx.preference:preference:1.1.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha2'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.appcompat:appcompat:1.7.0-alpha01'
implementation 'androidx.preference:preference:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0-alpha05'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.android.billingclient:billing:5.1.0'
implementation 'com.airbnb.android:lottie:3.0.0'
implementation 'com.airbnb.android:lottie:5.2.0'
implementation 'com.github.duanhong169:colorpicker:1.1.6'
implementation 'com.github.duanhong169:checkerboarddrawable:1.0.2'
implementation 'com.google.android.material:material:1.8.0-beta01'
}

task buildTranslationArray {
doLast {
def foundLocales = new StringBuilder()
foundLocales.append("new String[]{")

fileTree("src/main/res").visit { FileVisitDetails details ->
if(details.file.path.endsWith("strings.xml")){
def languageCode = details.file.parent.tokenize('/').last().tokenize('\\').last().replaceAll('values-','').replaceAll('-r','-')
languageCode = (languageCode == "values") ? "en" : languageCode;
languageCode = (languageCode == "values") ? "en" : languageCode
foundLocales.append("\"").append(languageCode).append("\"").append(",")
}
}

foundLocales.append("}")
def foundLocalesString = foundLocales.toString().replaceAll(',}','}')
android.defaultConfig.buildConfigField "String[]", "TRANSLATION_ARRAY", foundLocalesString
}
}
preBuild.dependsOn buildTranslationArray
}
110,594 changes: 86,705 additions & 23,889 deletions app/proguard/mapping.txt

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": 3,
"artifactType": {
"type": "APK",
"kind": "Directory"
},
"applicationId": "eu.chainfire.holeylight",
"variantName": "release",
"elements": [
{
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 102,
"versionName": "1.02",
"outputFile": "HoleyLight-v1.02-20221215140154.apk"
}
],
"elementType": "File"
}
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="eu.chainfire.holeylight">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public DeviceSpecs(String device, boolean exact, String json, float dpAddScaleBa
/* Google Pixel 4a */ new DeviceSpecs("sunfish", true, jsonDefault, -7, 0, 5.5f, 5.5f, 3f, true, true),
/* Google Pixel 4a 5G */ new DeviceSpecs("bramble", true, jsonDefault, -7, 0, 3.5f, 3.5f, 3f, true, true),
/* Google Pixel 5 */ new DeviceSpecs("redfin", true, jsonDefault, -11.75f, 0, 3.25f, 4.75f, 3f, true, true),

/* Google Pixel 7 Pro */ new DeviceSpecs("cheetah", true, jsonDefault, -3, 0, 1.5f, .5f, 3f, true, true),
/* Samsung Generic */ new DeviceSpecs("_samsung", true, jsonDefault, 0, 0, 0, 0, 1f, true, false),
/* Google Generic */ new DeviceSpecs("_google", true, jsonDefault, 0, 0, 0, 0, 3f, true, false),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
public class Permissions {
private static final int NOTIFICATION_ID_PERMISSIONS = 2001;

public enum Needed { DEVICE_SUPPORT, DEVICE_OFFICIAL_SUPPORT, UNHIDE_NOTCH, COMPANION_DEVICE, READ_PHONE_STATE, NOTIFICATION_SERVICE, ACCESSIBILITY_SERVICE, BATTERY_OPTIMIZATION_EXEMPTION, AOD_HELPER_UPDATE, AOD_HELPER_PERMISSIONS, NONE }
public enum Needed { DEVICE_SUPPORT, POST_NOTIFICATIONS, DEVICE_OFFICIAL_SUPPORT, UNHIDE_NOTCH, COMPANION_DEVICE, READ_PHONE_STATE, NOTIFICATION_SERVICE, ACCESSIBILITY_SERVICE, BATTERY_OPTIMIZATION_EXEMPTION, AOD_HELPER_UPDATE, AOD_HELPER_PERMISSIONS, NONE }

public static boolean allowAODHelperUpdateNeeded = true;
public static boolean allowAODHelperPermissionsNeeded = true;
Expand Down Expand Up @@ -79,6 +79,8 @@ public static Needed detect(Context context, boolean aodHelper) {
return Needed.UNHIDE_NOTCH;
} else if (((CompanionDeviceManager)context.getSystemService(COMPANION_DEVICE_SERVICE)).getAssociations().size() == 0) {
return Needed.COMPANION_DEVICE;
} else if (ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED) {
return Needed.POST_NOTIFICATIONS;
} else if (ContextCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
return Needed.READ_PHONE_STATE;
} else if (!NotificationManagerCompat.getEnabledListenerPackages(context).contains(context.getPackageName())) {
Expand Down
18 changes: 18 additions & 0 deletions app/src/main/java/eu/chainfire/holeylight/ui/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
public class MainActivity extends BaseActivity implements Settings.OnSettingsChangedListener {
private static final int LOGCAT_DUMP_REQUEST_CODE = 12345;
private static final int PERMISSION_READ_PHONE_STATE_CODE = 12346;
private static final int PERMISSION_NOTIFICATION_CODE = 12347;

private Handler handler = null;
private Settings settings = null;
Expand Down Expand Up @@ -179,6 +180,23 @@ private void checkPermissions() {
String device = String.format("%s / %s / %s", Build.BRAND, Build.MANUFACTURER, Build.DEVICE);

switch (Permissions.detect(this, true)) {
case POST_NOTIFICATIONS:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
(currentDialog = newAlert(false)
.setTitle(getString(R.string.permission_required))
.setMessage(Html.fromHtml(getString(R.string.permission_notifications)))
.setPositiveButton(android.R.string.ok, (dialog, which) -> {

ActivityCompat.requestPermissions(
MainActivity.this,
new String[]{Manifest.permission.POST_NOTIFICATIONS},
PERMISSION_NOTIFICATION_CODE
);
})
.show()).setCanceledOnTouchOutside(false);
break;
}
break;
case DEVICE_SUPPORT:
(currentDialog = newAlert(!Settings.DEBUG)
.setTitle(R.string.error)
Expand Down
73 changes: 38 additions & 35 deletions app/src/main/java/eu/chainfire/holeylight/ui/SettingsFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,22 @@
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.ListView;
import android.widget.SeekBar;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.Locale;

import androidx.annotation.NonNull;
import androidx.preference.CheckBoxPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.PreferenceScreen;

import com.google.android.material.slider.Slider;

import eu.chainfire.holeylight.BuildConfig;
import eu.chainfire.holeylight.R;
import eu.chainfire.holeylight.animation.SpritePlayer;
Expand Down Expand Up @@ -168,7 +171,7 @@ private int getModeFromPreference(Preference preference) {
return -1;
}

private class TimeoutHelper {
private static class TimeoutHelper {
public TimeoutHelper() { }

public void save() { }
Expand All @@ -191,7 +194,7 @@ private class TimeoutTimeHelper extends TimeoutHelper {
2 * 60 * 60 * 1000
};

private final SeekBar seekBar;
private final Slider seekBar;
private final TextView textValue;
private final int mode;
private AlertDialog base;
Expand All @@ -202,22 +205,24 @@ public TimeoutTimeHelper(AlertDialog base, int seekBarId, int textValueId, int m
textValue = base.findViewById(textValueId);
this.mode = mode;
this.base = base;

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
seekBar.addOnChangeListener((slider, value, fromUser) -> {
textValue.setText(getDescriptionFromIndex((int) value));
base.setTitle(getDescriptionFromIndex((int) value));
});
seekBar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textValue.setText(getDescriptionFromIndex(progress));
base.setTitle(getDescriptionFromIndex(progress));
}
@Override public void onStartTrackingTouch(SeekBar seekBar) {
public void onStartTrackingTouch(@NonNull Slider slider) {

}
@Override public void onStopTrackingTouch(SeekBar seekBar) {

@Override
public void onStopTrackingTouch(@NonNull Slider slider) {
base.setTitle(R.string.settings_seen_on_timeout_title);
}
});
seekBar.setMax(VALUES.length - 1);
seekBar.setProgress(getIndexFromValue(settings.getSeenTimeout(mode)), false);
textValue.setText(getDescriptionFromIndex(seekBar.getProgress()));
seekBar.setValueTo(VALUES.length - 1);
seekBar.setValue(getIndexFromValue(settings.getSeenTimeout(mode)));
textValue.setText(getDescriptionFromIndex((int) seekBar.getValue()));
base.setTitle(R.string.settings_seen_on_timeout_title);
}

Expand All @@ -233,7 +238,7 @@ public int getValueFromIndex(int index) {
}

public int getValue() {
return getValueFromIndex(seekBar.getProgress());
return getValueFromIndex((int) seekBar.getValue());
}

public String getDescriptionFromIndex(int index) {
Expand Down Expand Up @@ -276,7 +281,7 @@ public void close() {
}

private class TimeoutLingerHelper extends TimeoutHelper {
private final SeekBar seekBar;
private final Slider seekBar;
private final TextView textValue;
private AlertDialog base;

Expand All @@ -285,22 +290,24 @@ public TimeoutLingerHelper(AlertDialog base, int seekBarId, int textValueId) {
seekBar = base.findViewById(seekBarId);
textValue = base.findViewById(textValueId);
this.base = base;

seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
seekBar.addOnChangeListener((slider, value, fromUser) -> {
textValue.setText(getDescriptionFromIndex((int) value));
base.setTitle(getDescriptionFromIndex((int) value));
});
seekBar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
textValue.setText(getDescriptionFromIndex(progress));
base.setTitle(getDescriptionFromIndex(progress));
}
@Override public void onStartTrackingTouch(SeekBar seekBar) {
public void onStartTrackingTouch(@NonNull Slider slider) {

}
@Override public void onStopTrackingTouch(SeekBar seekBar) {

@Override
public void onStopTrackingTouch(@NonNull Slider slider) {
base.setTitle(R.string.settings_animation_overlay_linger_title);
}
});
seekBar.setMax(20);
seekBar.setProgress(getIndexFromValue(settings.getOverlayLinger()), false);
textValue.setText(getDescriptionFromIndex(seekBar.getProgress()));
seekBar.setValueTo(20);
seekBar.setValue(getIndexFromValue(settings.getOverlayLinger()));
textValue.setText(getDescriptionFromIndex((int) seekBar.getValue()));
base.setTitle(R.string.settings_animation_overlay_linger_title);
}

Expand All @@ -313,7 +320,7 @@ public int getValueFromIndex(int index) {
}

public int getValue() {
return getValueFromIndex(seekBar.getProgress());
return getValueFromIndex((int) seekBar.getValue());
}

public String getDescriptionFromIndex(int index) {
Expand Down Expand Up @@ -342,12 +349,12 @@ private boolean supportsAODSchedule() {
private ListPreference getLocalesPreference(PreferenceCategory category) {
ArrayList<String> locales = new ArrayList<>();

AssetManager assetManager = getActivity().getAssets();
AssetManager assetManager = requireActivity().getAssets();
String[] assetLocales = assetManager.getLocales();
for (String s : assetLocales) {
String lang = s.replace("-", "_");

boolean found = BuildConfig.TRANSLATION_ARRAY.length == 0;
boolean found = false;
for (String match : BuildConfig.TRANSLATION_ARRAY) {
found = match.replace("-", "_").equals(lang);
if (found) break;
Expand Down Expand Up @@ -388,11 +395,7 @@ private ListPreference getLocalesPreference(PreferenceCategory category) {
right_locale = new Locale(right_lang);
}

if ((left_locale != null) && (right_locale != null)) {
return left_locale.getDisplayName().compareTo(right_locale.getDisplayName());
} else {
return 0;
}
return left_locale.getDisplayName().compareTo(right_locale.getDisplayName());
} else {
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/drawable/line.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@android:color/transparent" />
<solid android:color="?colorOnPrimary" />
<padding android:padding="0dp" />
</shape>
9 changes: 8 additions & 1 deletion app/src/main/res/drawable/thumb.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#4DFFFFFF" />
<corners android:radius="50dp" />

<padding
android:paddingLeft="22dp"
android:paddingRight="22dp" />

<solid android:color="?colorPrimary" />

</shape>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_height="match_parent"
tools:context=".ui.MainActivity">

<fragment
<androidx.fragment.app.FragmentContainerView
android:id="@+id/settings_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down
Loading