mirror of
https://github.com/FatttSnake/OxygenToolbox.git
synced 2026-04-06 15:01:25 +08:00
Optimized language, attr, themes, colors.
Change the way to launch tool activity.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import static androidx.core.content.ContextCompat.startActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.fatapp.oxygentoolbox.tools.TimeScreenActivity;
|
||||
|
||||
public class BasicToolsLauncher {
|
||||
public static void launch(int activity, Context context) {
|
||||
switch (activity) {
|
||||
case 0:
|
||||
startActivity(context, new Intent(context, TimeScreenActivity.class), null);
|
||||
break;
|
||||
case 1:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.res.Resources;
|
||||
|
||||
public final class ResourceUtil {
|
||||
|
||||
private static Application sApp;
|
||||
private static Resources sRes;
|
||||
|
||||
public static void init(Application app) {
|
||||
sApp = app;
|
||||
sRes = app.getResources();
|
||||
}
|
||||
|
||||
public static Application getApplication() {
|
||||
return sApp;
|
||||
}
|
||||
|
||||
public static Resources getResources() {
|
||||
return sRes;
|
||||
}
|
||||
|
||||
public static String getString(int resId) {
|
||||
return sRes.getString(resId);
|
||||
}
|
||||
|
||||
public static int getColor(int resId) {
|
||||
return sRes.getColor(resId);
|
||||
}
|
||||
}
|
||||
@@ -166,7 +166,7 @@ public class ToolsJson {
|
||||
@SerializedName("text")
|
||||
private Text text;
|
||||
@SerializedName("activity")
|
||||
private Integer activity;
|
||||
private String activity;
|
||||
|
||||
public Text getText() {
|
||||
return text;
|
||||
@@ -176,11 +176,11 @@ public class ToolsJson {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getActivity() {
|
||||
public String getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
public void setActivity(Integer activity) {
|
||||
public void setActivity(String activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.fatapp.oxygentoolbox.util;
|
||||
|
||||
import static androidx.core.content.ContextCompat.startActivity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.fatapp.oxygentoolbox.R;
|
||||
import com.fatapp.oxygentoolbox.tools.TimeScreenActivity;
|
||||
|
||||
public class ToolsLauncher {
|
||||
public static void launch(Context context, String activity) {
|
||||
try {
|
||||
startActivity(context, new Intent(context, Class.forName(activity)), null);
|
||||
} catch (ClassNotFoundException e) {
|
||||
Toast.makeText(context, R.string.activity_class_not_found, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,9 +46,9 @@ public class ToolsList {
|
||||
private static String getLocale(Locales strings) {
|
||||
String language;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
language = MainActivity.mainActivity.getResources().getConfiguration().getLocales().get(0).getLanguage();
|
||||
language = ResourceUtil.getResources().getConfiguration().getLocales().get(0).getLanguage();
|
||||
} else {
|
||||
language = MainActivity.mainActivity.getResources().getConfiguration().locale.getLanguage();
|
||||
language = ResourceUtil.getResources().getConfiguration().locale.getLanguage();
|
||||
}
|
||||
if (language.equals("zh")) {
|
||||
return strings.getCn();
|
||||
@@ -105,7 +105,7 @@ public class ToolsList {
|
||||
|
||||
public static class Button {
|
||||
private String text;
|
||||
private Integer activity;
|
||||
private String activity;
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
@@ -115,11 +115,11 @@ public class ToolsList {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getActivity() {
|
||||
public String getActivity() {
|
||||
return activity;
|
||||
}
|
||||
|
||||
public void setActivity(Integer activity) {
|
||||
public void setActivity(String activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user