Permalink
Browse files

SubstratumUI: Instantiate new launching mechanism

Allow users to have custom activities and classes in their themes!
  • Loading branch information...
1 parent fe30d05 commit 58662f43b9ce86ec8c5235b2dedbc403099f75a6 @nicholaschum committed Dec 19, 2016
@@ -17,7 +17,6 @@
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent currentIntent = getIntent();
- String theme_name = currentIntent.getStringExtra("theme_name");
String theme_pid = currentIntent.getStringExtra("theme_pid");
SharedPreferences prefs = this.getSharedPreferences(
@@ -30,7 +29,7 @@ protected void onCreate(Bundle savedInstanceState) {
File checkSubstratumVerity = new File(this.getCacheDir()
.getAbsoluteFile() + "/SubstratumBuilder/" + theme_pid + "/substratum.xml");
if (checkSubstratumVerity.exists()) {
- References.launchTheme(this, theme_name, theme_pid, null);
+ References.launchTheme(this, theme_pid, null, false);
} else {
Toast toast = Toast.makeText(this, this.getString(R.string.toast_needs_caching),
Toast.LENGTH_LONG);
@@ -125,9 +125,9 @@ public void onClick(View v) {
information.get(i).getThemePackage() + "/substratum.xml");
if (checkSubstratumVerity.exists()) {
References.launchTheme(information.get(i).getContext(),
- information.get(i).getThemeName(), information.get(i)
+ information.get(i)
.getThemePackage(), information.get(i)
- .getThemeMode());
+ .getThemeMode(), false);
} else {
new References.SubstratumThemeUpdate(
information.get(i).getContext(),
@@ -25,13 +25,10 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Date;
import java.util.HashMap;
import java.util.List;
-import java.util.Locale;
import projekt.substrate.LetsGetStarted;
import projekt.substrate.ShowMeYourFierceEyes;
@@ -774,59 +771,12 @@ public static String getDeviceIMEI(Context context) {
}
// Launch intent for a theme
- public static boolean launchTheme(Context mContext, String theme_name, String package_name,
- String theme_mode) {
- try {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss", Locale.getDefault());
- long currentDateAndTime = Long.parseLong(sdf.format(new Date()));
-
- String parse1_themeName = theme_name.replaceAll("\\s+", "");
- String parse2_themeName = parse1_themeName.replaceAll("[^a-zA-Z0-9]+", "");
-
- SharedPreferences prefs = mContext.getSharedPreferences(
- "filter_state", Context.MODE_PRIVATE);
- long saved_time = prefs.getLong(parse2_themeName + "_saved_time", 0);
-
- if (currentDateAndTime > saved_time && String.valueOf(currentDateAndTime).length() ==
- String.valueOf(saved_time).length() && saved_time != 0 &&
- !References.isPackageInstalled(mContext, References.lp_package_identifier)) {
- long initializer = LetsGetStarted.initialize(mContext, package_name,
- !References.checkOMS(mContext), theme_mode, References.DEBUG, saved_time);
- if (initializer == 8256663 * 3) {
- Log.e(References.SUBSTRATUM_LOG, "\"" + package_name + "\"" +
- " has been reported stolen on device [" +
- getDeviceIMEI(mContext) + "]");
- return false;
- }
- return true;
- } else {
- long checker = LetsGetStarted.initialize(mContext,
- package_name,
- !References.checkOMS(mContext), theme_mode, References.DEBUG, saved_time);
- if (checker > -1) {
- if (checker == 8256663 * 3) {
- Log.e(References.SUBSTRATUM_LOG, "\"" + package_name + "\"" +
- " has been reported stolen on device [" +
- getDeviceIMEI(mContext) + "]");
- return false;
- }
- prefs.edit().putLong(
- parse2_themeName + "_saved_time", currentDateAndTime).apply();
- return true;
- } else {
- Toast toast = Toast.makeText(mContext,
- mContext.getString(R.string
- .information_activity_pirated_toast),
- Toast.LENGTH_LONG);
- toast.show();
- }
- }
- } catch (Exception ex) {
- Toast toast = Toast.makeText(mContext,
- mContext.getString(R.string
- .information_activity_upgrade_toast),
- Toast.LENGTH_LONG);
- toast.show();
+ public static boolean launchTheme(Context mContext, String package_name, String theme_mode,
+ Boolean notification) {
+ Intent initializer = LetsGetStarted.initialize(mContext, package_name,
+ !References.checkOMS(mContext), theme_mode, notification);
+ if (initializer != null) {
+ mContext.startActivity(initializer);
}
return false;
}
@@ -1051,7 +1001,7 @@ protected void onPostExecute(String result) {
if (launch) {
toast.show();
// At this point, we can safely assume that the theme has successfully extracted
- launchTheme(mContext, theme_name, theme_package, theme_mode);
+ launchTheme(mContext, theme_package, theme_mode, false);
} else {
toast2.show();
// We don't want this cache anymore, delete it from the system completely
@@ -86,8 +86,8 @@ protected void onPostExecute(String result) {
intent = PendingIntent.getActivity(mContext, 0, notificationIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
} else {
- Intent myIntent = LetsGetStarted.notifier(mContext, packageName,
- false, null, References.DEBUG);
+ Intent myIntent = LetsGetStarted.initialize(mContext, packageName,
+ false, null, true);
if (myIntent != null) {
intent = PendingIntent.getActivity(mContext, 0, myIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
@@ -132,8 +132,8 @@ protected void onPostExecute(String result) {
intent = PendingIntent.getActivity(mContext, 0, notificationIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
} else {
- Intent myIntent = LetsGetStarted.notifier(mContext, packageName,
- false, null, References.DEBUG);
+ Intent myIntent = LetsGetStarted.initialize(mContext, packageName,
+ false, null, true);
if (myIntent != null) {
intent = PendingIntent.getActivity(mContext, 0, myIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
Binary file not shown.

0 comments on commit 58662f4

Please sign in to comment.