Migrate to AppCompat

This commit is contained in:
SVolf 2023-10-01 22:13:37 +07:00 committed by TrianguloY
parent 6bafc4c72b
commit a60e59f2cd
29 changed files with 97 additions and 143 deletions

View file

@ -142,4 +142,6 @@ dependencies {
implementation libs.lsvg
implementation libs.flows
implementation libs.koin.android
implementation libs.androidx.appcomat
implementation libs.androidx.material
}

View file

@ -24,22 +24,23 @@ SOFTWARE.
package net.pierrox.lightning_launcher;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import net.pierrox.lightning_launcher_extreme.R;
import androidx.appcompat.app.AppCompatActivity;
import net.pierrox.lightning_launcher.iab.IabHelper;
import net.pierrox.lightning_launcher.iab.IabResult;
import net.pierrox.lightning_launcher.iab.Inventory;
import net.pierrox.lightning_launcher.iab.Purchase;
import net.pierrox.lightning_launcher_extreme.R;
import java.util.ArrayList;
public class PurchaseProcess extends Activity {
public class PurchaseProcess extends AppCompatActivity {
private static final int REQUEST_PURCHASE_UNLOCK = 1;
private static final String INTENT_EXTRA_SKU = "sku";

View file

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppDialog" parent="android:Theme.Material.Light.Dialog.NoActionBar">
<item name="android:colorPrimary">@color/color_primary</item>
<item name="android:colorPrimaryDark">@color/color_primary_dark</item>
<item name="android:colorAccent">@color/color_accent</item>
</style>
</resources>

View file

@ -54,7 +54,7 @@
<application
android:name="net.pierrox.lightning_launcher.${app_name}"
android:icon="@drawable/icon"
android:theme="@style/AppLightTranslucent"
android:theme="@style/AppLight"
android:label="@string/app_name">
<activity
@ -184,8 +184,7 @@
android:name="net.pierrox.lightning_launcher.activities.CustomizeA"
android:configChanges="keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:label="@string/customize_ll"
android:theme="@style/AppLightTranslucent" />
android:label="@string/customize_ll" />
<activity
android:name="net.pierrox.lightning_launcher.activities.ScriptEditor"

View file

@ -133,7 +133,7 @@ public class ApplyTemplate extends ResourceWrapperActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME);
super.onCreate(savedInstanceState);

View file

@ -59,7 +59,6 @@ import net.pierrox.lightning_launcher.data.FileUtils;
import net.pierrox.lightning_launcher.data.Folder;
import net.pierrox.lightning_launcher.data.Item;
import net.pierrox.lightning_launcher.data.Page;
import net.pierrox.lightning_launcher.data.Utils;
import net.pierrox.lightning_launcher.util.FileProvider;
import net.pierrox.lightning_launcher_extreme.R;
@ -100,7 +99,7 @@ public class BackupRestore extends ResourceWrapperActivity implements View.OnCli
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME);
super.onCreate(savedInstanceState);

View file

@ -506,7 +506,7 @@ public class Customize extends ResourceWrapperActivity implements
protected void onCreate(Bundle savedInstanceState) {
// do not set the theme if we are a subclass
if (getClass() == Customize.class) {
Utils.setTheme(this, Utils.APP_THEME);
}
super.onCreate(savedInstanceState);

View file

@ -485,8 +485,6 @@ public class Dashboard extends ResourceWrapperActivity implements OnLongClickLis
@Override
public void onCreate(Bundle savedInstanceState) {
// Utils.setTheme(this, Utils.APP_THEME_NO_ACTION_BAR_WALLPAPER);
super.onCreate(savedInstanceState);
mHandler = new Handler();

View file

@ -122,7 +122,7 @@ public class EventActionSetup extends ResourceWrapperActivity implements Adapter
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME_NO_ACTION_BAR);
super.onCreate(savedInstanceState);

View file

@ -66,7 +66,7 @@ public class ImageCropper extends ResourceWrapperActivity implements View.OnClic
@Override
public void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME_NO_ACTION_BAR);
super.onCreate(savedInstanceState);
setContentView(R.layout.image_cropper);

View file

@ -160,7 +160,7 @@ public class ImagePicker extends ResourceWrapperActivity implements AdapterView.
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME_NO_ACTION_BAR);
super.onCreate(savedInstanceState);

View file

@ -42,7 +42,6 @@ import net.pierrox.lightning_launcher.LLApp;
import net.pierrox.lightning_launcher.Version;
import net.pierrox.lightning_launcher.data.ContainerPath;
import net.pierrox.lightning_launcher.data.Page;
import net.pierrox.lightning_launcher.data.Utils;
import net.pierrox.lightning_launcher.template.LLTemplateAPI;
import net.pierrox.lightning_launcher.util.PhoneUtils;
import net.pierrox.lightning_launcher_extreme.R;
@ -77,8 +76,6 @@ public class RootSettings extends PreferenceActivity implements OnPreferenceClic
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME);
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preference_root);

View file

@ -107,8 +107,6 @@ public class ScreenManager extends ResourceWrapperActivity implements OnClickLis
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME_NO_ACTION_BAR);
super.onCreate(savedInstanceState);
mLightningEngine = LLApp.get().getAppEngine();

View file

@ -304,7 +304,7 @@ public class ScriptEditor extends ResourceWrapperActivity implements View.OnClic
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME_NO_ACTION_BAR);
super.onCreate(savedInstanceState);

View file

@ -39,7 +39,6 @@ import net.pierrox.lightning_launcher.data.ContainerPath;
import net.pierrox.lightning_launcher.data.LightningIntent;
import net.pierrox.lightning_launcher.data.Page;
import net.pierrox.lightning_launcher.data.TaskerPlugin;
import net.pierrox.lightning_launcher.data.Utils;
import net.pierrox.lightning_launcher.engine.variable.Variable;
import net.pierrox.lightning_launcher.script.Script;
import net.pierrox.lightning_launcher.util.ScriptPickerDialog;
@ -94,7 +93,6 @@ public class Shortcuts extends ResourceWrapperListActivity {
mIsForTaskerScript = className.endsWith("TS");
mIsForTaskerVariable = className.endsWith("TV");
Utils.setTheme(this, mIsForTaskerScript ? Utils.APP_THEME_TRANSLUCENT : Utils.APP_THEME);
super.onCreate(savedInstanceState);

View file

@ -44,7 +44,6 @@ import net.pierrox.lightning_launcher.configuration.ShortcutConfig;
import net.pierrox.lightning_launcher.data.Box;
import net.pierrox.lightning_launcher.data.FileUtils;
import net.pierrox.lightning_launcher.data.JsonLoader;
import net.pierrox.lightning_launcher.data.Utils;
import net.pierrox.lightning_launcher_extreme.R;
import org.json.JSONException;
@ -68,9 +67,9 @@ public class StyleChooser extends ResourceWrapperListActivity implements OnItemL
@Override
protected void onCreate(Bundle savedInstanceState) {
Utils.setTheme(this, Utils.APP_THEME);
super.onCreate(savedInstanceState);
super.onCreate(savedInstanceState);
getListView().setOnItemLongClickListener(this);

View file

@ -24,7 +24,8 @@ SOFTWARE.
package net.pierrox.lightning_launcher.activities.dummy;
import android.app.Activity;
public class D1 extends Activity {
import androidx.appcompat.app.AppCompatActivity;
public class D1 extends AppCompatActivity {
}

View file

@ -24,7 +24,7 @@ SOFTWARE.
package net.pierrox.lightning_launcher.activities.dummy;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
public class D2 extends Activity {
public class D2 extends AppCompatActivity {
}

View file

@ -24,7 +24,8 @@ SOFTWARE.
package net.pierrox.lightning_launcher.activities.dummy;
import android.app.Activity;
public class D3 extends Activity {
import androidx.appcompat.app.AppCompatActivity;
public class D3 extends AppCompatActivity {
}

View file

@ -24,7 +24,7 @@ SOFTWARE.
package net.pierrox.lightning_launcher.activities.dummy;
import android.app.Activity;
import androidx.appcompat.app.AppCompatActivity;
public class D4 extends Activity {
public class D4 extends AppCompatActivity {
}

View file

@ -38,5 +38,7 @@ dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation files('libs/dx.jar')
implementation libs.lsvg
implementation libs.androidx.appcomat
implementation libs.androidx.material
implementation project(':plugin-api')
}

View file

@ -103,8 +103,6 @@ public abstract class LLApp extends Application {
SharedAsyncGraphicsDrawable.setPoolSize((long) (mSystemConfig.imagePoolSize * Runtime.getRuntime().maxMemory()));
// Utils.setTheme(this, Utils.APP_THEME);
if (mSystemConfig.language != null) {
mLanguage = mSystemConfig.language;

View file

@ -1,30 +1,41 @@
package net.pierrox.lightning_launcher.activities;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.Build;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.style.StyleSpan;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import net.pierrox.lightning_launcher.LLApp;
import net.pierrox.lightning_launcher.R;
import net.pierrox.lightning_launcher.configuration.SystemConfig;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class ResourceWrapperActivity extends Activity {
public abstract class ResourceWrapperActivity extends AppCompatActivity {
public static final int REQUEST_PERMISSION_BASE = 1000000;
public static final int REQUEST_PERMISSION_FONT_PICKER = REQUEST_PERMISSION_BASE + 1;
private ResourcesWrapperHelper mResourcesWrapperHelper;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTheme();
}
@Override
public final Resources getResources() {
if(mResourcesWrapperHelper == null) {
@ -37,6 +48,11 @@ public abstract class ResourceWrapperActivity extends Activity {
return super.getResources();
}
private void setTheme() {
boolean isLight = LLApp.get().getSystemConfig().appStyle == SystemConfig.AppStyle.LIGHT;
AppCompatDelegate.setDefaultNightMode(isLight ? AppCompatDelegate.MODE_NIGHT_NO : AppCompatDelegate.MODE_NIGHT_YES);
}
public boolean checkPermissions(String[] permissions, int[] rationales, final int requestCode) {
final ArrayList<String> permissionsToRequest = new ArrayList<>();
final ArrayList<String> permissionsToExplain = new ArrayList<>();

View file

@ -63,7 +63,6 @@ import net.pierrox.lightning_launcher.configuration.ItemConfig;
import net.pierrox.lightning_launcher.configuration.JsonFields;
import net.pierrox.lightning_launcher.configuration.PageConfig;
import net.pierrox.lightning_launcher.configuration.ShortcutConfig;
import net.pierrox.lightning_launcher.configuration.SystemConfig;
import net.pierrox.lightning_launcher.engine.LightningEngine;
import net.pierrox.lightning_launcher.engine.Screen;
import net.pierrox.lightning_launcher.script.Script;
@ -172,20 +171,10 @@ public class Utils {
// public static int getPageForOrientation(int p, int degrees) {
// return p%ORIENTATION_SHIFT + ORIENTATION_SHIFT*degrees;
// }
public static final int APP_THEME = 0;
public static final int APP_THEME_TRANSLUCENT = 1;
public static final int APP_THEME_NO_ACTION_BAR = 2;
public static final int APP_THEME_NO_ACTION_BAR_WALLPAPER = 3;
private static final Rect sTmpRect1 = new Rect();
private static final float DYNAMIC_FOLDER_BG_MARGIN = 0.03125f;
private static final Matrix sTempMatrix = new Matrix();
private static final RectF sTempRectF = new RectF();
private static final int[] sThemes = new int[]{
R.style.AppLight, R.style.AppDark,
R.style.AppLightTranslucent, R.style.AppDarkTranslucent,
R.style.AppLightNoActionBar, R.style.AppDarkNoActionBar,
R.style.AppLightNoActionBarWallpaper, R.style.AppDarkNoActionBarWallpaper,
};
public static Method sGetDrawableForDensity;
private static int sStandardIconSize;
private static int sLauncherIconDensity;
@ -2428,12 +2417,6 @@ public class Utils {
return 0;
}
public static void setTheme(Context context, int theme) {
boolean is_light = LLApp.get().getSystemConfig().appStyle == SystemConfig.AppStyle.LIGHT;
int style = sThemes[theme * 2 + (is_light ? 0 : 1)];
context.setTheme(style);
}
public static void copyResourceToFile(Resources resources, int id, File out) {
InputStream is = null;
FileOutputStream os = null;

View file

@ -1,19 +0,0 @@
<resources>
<style name="AppDark" parent="android:Theme.Holo" />
<style name="AppLight" parent="android:Theme.Holo.Light" />
<style name="AppDarkNoActionBarWallpaper" parent="android:Theme.Holo.NoActionBar">
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AppDarkNoActionBar" parent="android:Theme.Holo.NoActionBar" />
<style name="AppDarkTranslucent" parent="android:Theme.Holo.Dialog.NoActionBar" />
<style name="AppLightNoActionBarWallpaper" parent="android:Theme.Holo.Light.NoActionBar">
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AppLightNoActionBar" parent="android:Theme.Holo.Light.NoActionBar" />
<style name="AppLightTranslucent" parent="android:Theme.Holo.Light.Dialog.NoActionBar" />
<style name="AppDialog" parent="android:Theme.Holo.Light.Dialog.NoActionBar" />
</resources>

View file

@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppDark" parent="android:Theme.Material">
<item name="android:colorPrimary">@color/color_primary</item>
<item name="android:colorPrimaryDark">@color/color_primary_dark</item>
<item name="android:colorAccent">@color/color_accent</item>
</style>
<style name="AppLight" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimary">@color/color_primary</item>
<item name="android:colorPrimaryDark">@color/color_primary_dark</item>
<item name="android:colorAccent">@color/color_accent</item>
</style>
<style name="AppDarkNoActionBarWallpaper" parent="AppDark">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AppDarkNoActionBar" parent="AppDark">
<item name="android:windowNoTitle">true</item>
</style>
<style name="AppDarkTranslucent" parent="android:Theme.Material.Dialog.NoActionBar" />
<style name="AppLightNoActionBarWallpaper" parent="AppLight">
<!--<item name="android:windowNoTitle">true</item>-->
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AppLightNoActionBar" parent="AppLight">
<item name="android:windowNoTitle">true</item>
</style>
<style name="AppLightTranslucent" parent="android:Theme.Material.Light.Dialog.NoActionBar" />
<style name="AppDialog" parent="android:Theme.Material.Light.Dialog.NoActionBar">
<item name="android:colorPrimary">@color/color_primary</item>
<item name="android:colorPrimaryDark">@color/color_primary_dark</item>
<item name="android:colorAccent">@color/color_accent</item>
</style>
</resources>

View file

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppDark" parent="android:Theme.Material">
<item name="android:colorPrimary">@color/color_primary</item>
<item name="android:colorPrimaryDark">@color/color_primary_dark</item>
<item name="android:colorAccent">@color/color_accent</item>
<style name="AppDark" parent="@style/Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
<style name="AppLight" parent="android:Theme.Material.Light.DarkActionBar">
<item name="android:colorPrimary">@color/color_primary</item>
<item name="android:colorPrimaryDark">@color/color_primary_dark</item>
<item name="android:colorAccent">@color/color_accent</item>
<style name="AppLight" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>
</style>
</resources>

View file

@ -1,16 +1,40 @@
<resources>
<style name="AppDark" parent="android:Theme" />
<style name="AppLight" parent="AppDark" />
<style name="AppDarkNoActionBarWallpaper" parent="android:Theme.Wallpaper.NoTitleBar" />
<style name="AppDarkNoActionBar" parent="android:Theme.NoTitleBar" />
<style name="AppDarkTranslucent" parent="android:Theme.Translucent.NoTitleBar" />
<style name="AppDark" parent="@style/Theme.AppCompat.NoActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
</style>
<style name="AppLightNoActionBarWallpaper" parent="AppDarkNoActionBarWallpaper" />
<style name="AppLightNoActionBar" parent="AppDarkNoActionBar" />
<style name="AppLightTranslucent" parent="AppDarkTranslucent" />
<style name="AppDialog" parent="android:Theme.Dialog" />
<style name="AppLight" parent="@style/Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
</style>
<style name="AppDarkNoActionBarWallpaper" parent="AppDark">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AppDarkNoActionBar" parent="Theme.AppCompat.NoActionBar" />
<style name="AppLightNoActionBar" parent="Theme.AppCompat.Light.NoActionBar" />
<style name="AppLightNoActionBarWallpaper" parent="AppLight">
<!--<item name="android:windowNoTitle">true</item>-->
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
<style name="AppDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorPrimary">@color/color_primary</item>
<item name="colorPrimaryDark">@color/color_primary_dark</item>
<item name="colorAccent">@color/color_accent</item>
</style>
<style name="NoDisplay" parent="AppLightNoActionBarWallpaper">
<!--<item name="android:windowBackground">@android:color/transparent</item>-->

View file

@ -14,6 +14,9 @@ remoter-compiler = { module = "com.josesamuel:remoter", version.ref = "remoter_v
parceler = { module = "org.parceler:parceler-api", version.ref = "parceler_version" }
parceler-compiler = { module = "org.parceler:parceler", version.ref = "parceler_version" }
androidx-appcomat = { module = "androidx.appcompat:appcompat", version = "1.6.1" }
androidx-material = { module = "com.google.android.material:material", version = "1.9.0" }
flows = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version = "1.7.3" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin_version" }