The .gitignore removed the entire app for some reason

This commit is contained in:
2024-10-05 20:47:55 +02:00
parent 549d61ce90
commit 773c42beb4
8 changed files with 188 additions and 1 deletions
-1
View File
@@ -14,4 +14,3 @@
.externalNativeBuild
.cxx
local.properties
/app/
+1
View File
@@ -0,0 +1 @@
/build
+29
View File
@@ -0,0 +1,29 @@
plugins {
alias(libs.plugins.android.application)
}
android {
namespace 'cfpi_fpsi.eu.titan_mini_mode'
compileSdk 34
defaultConfig {
applicationId "cfpi_fpsi.eu.titan_mini_mode"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
+21
View File
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:label="@string/app_name"
android:supportsRtl="true"
tools:targetApi="31">
<!-- The Quick Settings tile.-->
<service android:name=".TitanMiniModeQSTileService"
android:exported="true"
android:icon="@drawable/qs_tile"
android:label="@string/qs_tile_label"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
<meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
android:value="true"/>
</service>
</application>
</manifest>
@@ -0,0 +1,107 @@
package cfpi_fpsi.eu.titan_mini_mode;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.Point;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;
import java.io.IOException;
public class TitanMiniModeQSTileService extends TileService {
SharedPreferences pref;
@Override
public void onTileAdded() {
super.onTileAdded();
pref = getBaseContext().getSharedPreferences(
"cfpi_fpsi.eu.titan_mini_mode.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE);
// When the tile is first added, we save the original screen size into the preferences.
DisplayMetrics metrics = Resources.getSystem().getDisplayMetrics();
SharedPreferences.Editor editor = pref.edit();
editor.putInt("original_screen_width", metrics.widthPixels);
editor.putInt("original_screen_height", metrics.heightPixels);
editor.commit();
}
@Override
public void onTileRemoved() {
super.onTileRemoved();
// When the tile is removed, we set the display size to the default.
Point originalScreenSize = getOriginalScreenSize();
setDisplaySize(originalScreenSize.x, originalScreenSize.y);
}
@Override
public void onStartListening() {
super.onStartListening();
pref = getBaseContext().getSharedPreferences(
"cfpi_fpsi.eu.titan_mini_mode.PREFERENCE_FILE_KEY", Context.MODE_PRIVATE);
Tile tile = getQsTile();
Point currentScreenSize = getCurrentScreenSize();
Point originalScreenSize = getOriginalScreenSize();
if (currentScreenSize.x == originalScreenSize.x
&& currentScreenSize.y == originalScreenSize.y) {
tile.setState(Tile.STATE_INACTIVE);
} else {
tile.setState(Tile.STATE_ACTIVE);
}
tile.updateTile();
}
@Override
public void onClick() {
super.onClick();
Tile tile = getQsTile();
Point currentScreenSize = getCurrentScreenSize();
Point originalScreenSize = getOriginalScreenSize();
if (currentScreenSize.x == originalScreenSize.x &&
currentScreenSize.y == originalScreenSize.y) {
setDisplaySize(Math.round(originalScreenSize.x * 0.66), originalScreenSize.y);
tile.setState(Tile.STATE_ACTIVE);
} else {
setDisplaySize(originalScreenSize.x, originalScreenSize.y);
tile.setState(Tile.STATE_INACTIVE);
}
tile.updateTile();
}
static void setDisplaySize(long x, long y) {
runAsRoot("wm size " + x + "x" + y);
}
// https://github.com/rumplestilzken/gargoyleSettings/blob/main/app/src/main/java/com/rumplestilzken/gargoylesettings/provider/RootProvider.java
static void runAsRoot(String command) {
try {
Process root = Runtime.getRuntime().exec(new String[] { "su", "-c", command});
try {
root.waitFor();
} catch (InterruptedException e) {
Log.d("EXCEPTION", e.toString());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private Point getOriginalScreenSize() {
return new Point(pref.getInt("original_screen_width", 1440),
pref.getInt("original_screen_height", 1440));
}
private Point getCurrentScreenSize() {
WindowManager wm = (WindowManager) getBaseContext().getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
Point size = new Point();
display.getSize(size);
return size;
}
}
+5
View File
@@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:autoMirrored="true" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M12,7C6.48,7 2,9.24 2,12c0,2.24 2.94,4.13 7,4.77V20l4,-4 -4,-4v2.73c-3.15,-0.56 -5,-1.9 -5,-2.73 0,-1.06 3.04,-3 8,-3s8,1.94 8,3c0,0.73 -1.46,1.89 -4,2.53v2.05c3.53,-0.77 6,-2.53 6,-4.58 0,-2.76 -4.48,-5 -10,-5z"/>
</vector>
+4
View File
@@ -0,0 +1,4 @@
<resources>
<string name="app_name">Titan Mini Mode</string>
<string name="qs_tile_label">Mini mode</string>
</resources>