Skip to content
This repository has been archived by the owner on May 12, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/release' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
AsdMonio committed Nov 9, 2018
2 parents 3dbb8cf + 7e933b4 commit a22f74d
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 129 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ android {
applicationId "projekt.substratum"
minSdkVersion 24
targetSdkVersion 28
versionCode 1009
versionName "one thousand nine"
versionCode 1010
versionName "one thousand ten"
buildConfigField "java.util.Date", "buildTime", "new java.util.Date(" + System.currentTimeMillis() + "L)"
buildConfigField "String", "GIT_HASH", "\"${gitHash()}\""
buildConfigField "boolean", "ENHANCED_LOGGING", "false"
Expand Down
13 changes: 5 additions & 8 deletions app/src/main/java/projekt/substratum/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ private void switchFragment(String fragment) {
switchToStockToolbar(getString(R.string.nav_main));
}

if (!Systems.checkOMS(context) || isSamsung(context)) {
bottomBar.getMenu().removeItem(R.id.tab_priorities);
bottomBar.getMenu().removeItem(R.id.tab_profiles);
}

FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
tx.replace(R.id.main, Fragment.instantiate(this, fragment));
tx.commitAllowingStateLoss();
Expand Down Expand Up @@ -319,14 +324,6 @@ protected void onCreate(Bundle savedInstanceState) {
getSupportActionBar().setDisplayShowHomeEnabled(false);

bottomBar.setLabelVisibilityMode(LabelVisibilityMode.LABEL_VISIBILITY_LABELED);
BottomNavigationMenuView menuView = (BottomNavigationMenuView) bottomBar.getChildAt(0);
if (Systems.checkOMS(context) && !isSamsung(context)) {
menuView.findViewById(R.id.tab_priorities).setVisibility(View.VISIBLE);
menuView.findViewById(R.id.tab_profiles).setVisibility(View.VISIBLE);
} else {
menuView.findViewById(R.id.tab_priorities).setVisibility(View.GONE);
menuView.findViewById(R.id.tab_profiles).setVisibility(View.GONE);
}

bottomBar.setOnNavigationItemSelectedListener(item -> {
switch (item.getItemId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,87 +63,67 @@ public ThemeAdapter.ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup,
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder,
int pos) {
ThemeItem themeItem = this.information.get(pos);
final ThemeItem themeItem = this.information.get(pos);
this.context = themeItem.getContext();
ThemeEntryCardBinding viewHolderBinding = viewHolder.getBinding();
SharedPreferences prefs = Substratum.getPreferences();
final ThemeEntryCardBinding viewHolderBinding = viewHolder.getBinding();
final SharedPreferences prefs = Substratum.getPreferences();

viewHolderBinding.themeCard.setOnClickListener(
v -> Theming.launchTheme(this.context, themeItem.getThemePackage()));

viewHolderBinding.themeCard.setOnLongClickListener(view -> {
// Vibrate the device alerting the user they are about to do something dangerous!
if (Packages.isUserApp(this.context, themeItem.getThemePackage())) {
Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(30L);
}
Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE);
if (v != null) {
v.vibrate(30L);
}

// About the theme
SheetDialog sheetDialog = new SheetDialog(this.context);
View sheetView =
View.inflate(this.context,
R.layout.theme_entry_long_press_sheet_dialog, null);
ThemeEntryLongPressSheetDialogBinding sheetDialogBinding = DataBindingUtil.bind(sheetView);

assert sheetDialogBinding != null;
TextView aboutText = sheetDialogBinding.aboutText;
aboutText.setText(themeItem.getThemeName());
aboutText.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
sheetDialogBinding.moreText.setText(String.format("%s (%s)\n%s",
Packages.getAppVersion(this.context, themeItem.getThemePackage()),
Packages.getAppVersionCode(this.context, themeItem.getThemePackage()),
Packages.getPackageTemplateVersion(this.context,
themeItem.getThemePackage())));

sheetDialogBinding.icon
.setImageDrawable(Packages.getAppIcon(this.context, themeItem
.getThemePackage()));

// Favorite
LinearLayout favorite = sheetDialogBinding.favorite;

Drawable favoriteImg = this.context.getDrawable(R.drawable.toolbar_favorite);
Drawable notFavoriteImg =
this.context.getDrawable(R.drawable.toolbar_not_favorite);
TextView favoriteText = sheetView.findViewById(R.id.favorite_text);
if (prefs.getString("app_shortcut_theme", "").equals(themeItem.getThemePackage())) {
assert favoriteImg != null;
favoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(favoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_unfavorite));
} else {
assert notFavoriteImg != null;
notFavoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(notFavoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_favorite));
}
// About the theme
SheetDialog sheetDialog = new SheetDialog(this.context);
View sheetView =
View.inflate(this.context,
R.layout.theme_entry_long_press_sheet_dialog, null);
ThemeEntryLongPressSheetDialogBinding sheetDialogBinding = DataBindingUtil.bind(sheetView);

assert sheetDialogBinding != null;
TextView aboutText = sheetDialogBinding.aboutText;
aboutText.setText(themeItem.getThemeName());
aboutText.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
sheetDialogBinding.moreText.setText(String.format("%s (%s)\n%s",
Packages.getAppVersion(this.context, themeItem.getThemePackage()),
Packages.getAppVersionCode(this.context, themeItem.getThemePackage()),
Packages.getPackageTemplateVersion(this.context,
themeItem.getThemePackage())));

sheetDialogBinding.icon
.setImageDrawable(Packages.getAppIcon(this.context, themeItem
.getThemePackage()));

// Favorite
LinearLayout favorite = sheetDialogBinding.favorite;

Drawable favoriteImg = this.context.getDrawable(R.drawable.toolbar_favorite);
Drawable notFavoriteImg =
this.context.getDrawable(R.drawable.toolbar_not_favorite);
TextView favoriteText = sheetView.findViewById(R.id.favorite_text);
if (prefs.getString("app_shortcut_theme", "").equals(themeItem.getThemePackage())) {
assert favoriteImg != null;
favoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(favoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_unfavorite));
} else {
assert notFavoriteImg != null;
notFavoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(notFavoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_favorite));
}

favorite.setOnClickListener(view1 -> {
if (prefs.contains("app_shortcut_theme")) {
if (!prefs.getString("app_shortcut_theme", "").equals(
themeItem.getThemePackage())) {
prefs.edit().remove("app_shortcut_theme").apply();
References.clearShortcut(this.context);
prefs.edit().putString("app_shortcut_theme",
themeItem.getThemePackage()).apply();
References.createShortcut(
this.context,
themeItem.getThemePackage(),
themeItem.getThemeName());
assert favoriteImg != null;
favoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(favoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_unfavorite));
} else {
prefs.edit().remove("app_shortcut_theme").apply();
References.clearShortcut(this.context);
assert notFavoriteImg != null;
notFavoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(notFavoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_favorite));
}
} else {
favorite.setOnClickListener(view1 -> {
if (prefs.contains("app_shortcut_theme")) {
if (!prefs.getString("app_shortcut_theme", "").equals(
themeItem.getThemePackage())) {
prefs.edit().remove("app_shortcut_theme").apply();
References.clearShortcut(this.context);
prefs.edit().putString("app_shortcut_theme",
themeItem.getThemePackage()).apply();
References.createShortcut(
Expand All @@ -154,59 +134,81 @@ public void onBindViewHolder(@NonNull ViewHolder viewHolder,
favoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(favoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_unfavorite));
} else {
prefs.edit().remove("app_shortcut_theme").apply();
References.clearShortcut(this.context);
assert notFavoriteImg != null;
notFavoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(notFavoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_favorite));
}
});

// Rate Theme
LinearLayout rate = sheetDialogBinding.rate;
String installer =
Packages.getInstallerId(this.context, themeItem.getThemePackage());
if ((installer != null) && installer.equals(PLAY_STORE_PACKAGE_NAME)) {
rate.setVisibility(View.VISIBLE);
} else {
rate.setVisibility(View.GONE);
prefs.edit().putString("app_shortcut_theme",
themeItem.getThemePackage()).apply();
References.createShortcut(
this.context,
themeItem.getThemePackage(),
themeItem.getThemeName());
assert favoriteImg != null;
favoriteImg.setBounds(0, 0, 60, 60);
favoriteText.setCompoundDrawables(favoriteImg, null, null, null);
favoriteText.setText(this.context.getString(R.string.menu_unfavorite));
}
rate.setOnClickListener(view12 -> {
try {
String playURL = PLAY_URL_PREFIX + themeItem.getThemePackage();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(playURL));
this.context.startActivity(i);
} catch (ActivityNotFoundException activityNotFoundException) {
Toast.makeText(
this.context,
this.context.getString(R.string.activity_missing_toast),
Toast.LENGTH_SHORT).show();
}
sheetDialog.dismiss();
});

// Shortcut
LinearLayout shortcut = sheetDialogBinding.shortcut;
shortcut.setOnClickListener(view12 -> {
References.createLauncherIcon(this.context,
themeItem.getThemePackage(), themeItem.getThemeName());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
Toast.makeText(
this.context,
this.context.getString(R.string.launcher_shortcut_toast),
Toast.LENGTH_SHORT).show();
}
sheetDialog.dismiss();
});

// Uninstalling
LinearLayout uninstall = sheetDialogBinding.uninstall;
});

// Rate Theme
LinearLayout rate = sheetDialogBinding.rate;
String installer =
Packages.getInstallerId(this.context, themeItem.getThemePackage());
if ((installer != null) && installer.equals(PLAY_STORE_PACKAGE_NAME)) {
rate.setVisibility(View.VISIBLE);
} else {
rate.setVisibility(View.GONE);
}
rate.setOnClickListener(view12 -> {
try {
String playURL = PLAY_URL_PREFIX + themeItem.getThemePackage();
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(playURL));
this.context.startActivity(i);
} catch (ActivityNotFoundException activityNotFoundException) {
Toast.makeText(
this.context,
this.context.getString(R.string.activity_missing_toast),
Toast.LENGTH_SHORT).show();
}
sheetDialog.dismiss();
});

// Shortcut
LinearLayout shortcut = sheetDialogBinding.shortcut;
shortcut.setOnClickListener(view12 -> {
References.createLauncherIcon(this.context,
themeItem.getThemePackage(), themeItem.getThemeName());
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
Toast.makeText(
this.context,
this.context.getString(R.string.launcher_shortcut_toast),
Toast.LENGTH_SHORT).show();
}
sheetDialog.dismiss();
});

// Uninstalling
LinearLayout uninstall = sheetDialogBinding.uninstall;
if (!Packages.isUserApp(this.context, themeItem.getThemePackage())) {
uninstall.setVisibility(View.GONE);
} else {
uninstall.setOnClickListener(view2 -> {
Uri packageURI = Uri.parse("package:" + themeItem.getThemePackage());
Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI);
this.context.startActivity(uninstallIntent);
sheetDialog.dismiss();
});

sheetDialog.setContentView(sheetView);
sheetDialog.show();
}

sheetDialog.setContentView(sheetView);
sheetDialog.show();
return false;
});
viewHolderBinding.setThemeItem(themeItem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -747,16 +747,16 @@ protected void onPostExecute(Void result) {
if (alphabetize) {
fragment.overlaysList.sort(
Comparator.comparing(ManagerItem::getLabelName,
String.CASE_INSENSITIVE_ORDER)
Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER))
.thenComparing(ManagerItem::getThemeName,
String.CASE_INSENSITIVE_ORDER)
Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER))
);
} else {
fragment.overlaysList.sort(
Comparator.comparing(ManagerItem::getThemeName,
String.CASE_INSENSITIVE_ORDER)
Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER))
.thenComparing(ManagerItem::getLabelName,
String.CASE_INSENSITIVE_ORDER));
Comparator.nullsFirst(String.CASE_INSENSITIVE_ORDER)));
}
}

Expand Down

0 comments on commit a22f74d

Please sign in to comment.