[Xposed Framework Modules] Typhus_:
Hello!

I'm still trying to update this module. But it's not easy, at least for me it isn't.

Until 3 weeks ago I've never seen Java nor Xposed module's "insides". So, as you may tell, this is really difficult for me to achieve.

I need help in order to get this working as it should.

So, please help me. I'm not sure what to do even though I've tried different approaches. For the last weeks I've been reading and trying to learn everything there is to know about android.widget.progressbar; android.graphics.drawable.Drawable and android.graphics.drawable.AnimationDrawable. I've, as well, read both [MENTION=5290145]hamzahrmalik[/MENTION] and [MENTION=4419114]rovo89[/MENTION] tutorials about Xposed modules.

As mentioned before, my knowledge on this matter is insufficient but I really like to learn and I'll try everything to get this module working with the circular feature.

[MENTION=2011359]MohammadAG[/MENTION] original code to get the custom horizontal indeterminate progress bar working was this:

package com.mohammadag.smoothsystemprogressbars;

import android.graphics.drawable.Drawable;
import android.widget.ProgressBar;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;

public class SmoothSystemPBar implements IXposedHookZygoteInit {
private SettingsHelper mSettingsHelper;

@Override
public void initZygote(StartupParam startupParam) throws Throwable {
mSettingsHelper = new SettingsHelper();

XposedHelpers.findAndHookMethod(ProgressBar.class, "setIndeterminateDrawable", Drawable.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

Drawable b = (Drawable) param.args[0];
if (b == null)
return;

ProgressBar progressBar = (ProgressBar) param.thisObject;
if (progressBar == null)
return;

if (progressBar.getIndeterminateDrawable() instanceof SmoothProgressDrawable)
return;

mSettingsHelper.reloadSettings();

final float scale = progressBar.getResources().getDisplayMetrics().density;
if ("android.graphics.drawable.AnimationDrawable".equals(b.getClass().getName())) {
Drawable drawable = new SmoothProgressDrawable.Builder(progressBar.getContext())
.interpolator(mSettingsHelper.getProgressBarInterpolator())
.sectionsCount(mSettingsHelper.getSectionsCount())
.separatorLength(mSettingsHelper.getProgressSeparatorLength())
.strokeWidth(mSettingsHelper.getStrokeWidth(scale))
.speed(mSettingsHelper.getSpeed())
.mirrorMode(mSettingsHelper.getMirrored())
.reversed(mSettingsHelper.getReversed())
.colors(mSettingsHelper.getProgressBarColors())
.build();
progressBar.setIndeterminateDrawable(drawable);

param.args[0] = drawable;

}
}
});
}

}

I've then added this (navy color stuff):

package com.mohammadag.smoothsystemprogressbars;

import android.graphics.drawable.Drawable;
import android.widget.ProgressBar;
import de.robv.android.xposed.IXposedHookZygoteInit;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;

public class SmoothSystemPBar implements IXposedHookZygoteInit {
private SettingsHelper mSettingsHelper;

@Override
public void initZygote(StartupParam startupParam) throws Throwable {
mSettingsHelper = new SettingsHelper();

XposedHelpers.findAndHookMethod(ProgressBar.class, "setIndeterminateDrawable", Drawable.class, new XC_MethodHook() {
@Override
protected void beforeHookedMethod(MethodHookParam param) throws Throwable {

Drawable b = (Drawable) param.args[0];
if (b == null)
return;

ProgressBar progressBar = (ProgressBar) param.thisObject;
if (progressBar == null)
return;

if (progressBar.getIndeterminateDrawable() instanceof SmoothProgressDrawable)
return;

mSettingsHelper.reloadSettings();

final float scale = progressBar.getResources().getDisplayMetrics().density;
if ("android.graphics.drawable.AnimationDrawable".equals(b.getClass().getName())) {
Drawable drawable = new SmoothProgressDrawable.Builder(progressBar.getContext())
.interpolator(mSettingsHelper.getProgressBarInterpolator())
.sectionsCount(mSettingsHelper.getSectionsCount())
.separatorLength(mSettingsHelper.getProgressSeparatorLength())
.strokeWidth(mSettingsHelper.getStrokeWidth(scale))
.speed(mSettingsHelper.getSpeed())
.mirrorMode(mSettingsHelper.getMirrored())
.reversed(mSettingsHelper.getReversed())
.colors(mSettingsHelper.getProgressBarColors())
.build();
progressBar.setIndeterminateDrawable(drawable);

param.args[0] = drawable;

}

[COLOR="Navy"]if (progressBar.getIndeterminateDrawable() instanceof CircularProgressDrawable)
return;

mSettingsHelper.reloadSettings();

final float scale1 = progressBar.getResources().getDisplayMetrics().density;
if ("android.graphics.drawable.AnimationDrawable".equals(b.getClass().getName())) {
Drawable circle = new CircularProgressDrawable.Builder(progressBar.getContext())
.colors(mSettingsHelper.getProgressBarColors())
.strokeWidth(mSettingsHelper.getStrokeWidth(scale1))
.sweepSpeed(mSettingsHelper.getSpeed())
.rotationSpeed(mSettingsHelper.getSpeed())
.sweepInterpolator(mSettingsHelper.getProgressBarInterpolator())
.style(CircularProgressDrawable.Style.ROUNDED)
.build();

progressBar.setIndeterminateDrawable(circle);

param.args[0] = circle;

}[/COLOR]
}
});
}

}

Final result was -> The horizontal indeterminate progress bar gets replaced by a circular one but within it's layout dimensions...so it gets flatten, "eclipsed" I mean. As for the "spinners" (that's my primary goal) those keep untouched.

From "android.widget.ProgressBar" -> By default, the progress bar is a spinning wheel (an indeterminate indicator). To change to a horizontal progress bar, apply the Widget.ProgressBar.Horizontal style.

Can a style be "forced" by Java code?

Is it possible to program something like this:

1 - Get android's default indeterminate progressBar attributes

2 - If "indeterminate progressBar style" is "Widget.ProgressBar.Horizontal" -> Replace default indeterminate porgressBar drawable by SmoothProgressBar drawable

3 - Else -> Replace default indeterminate progressBar drawable by CircularProgressBar drawable

?

How to hook into this? The thing is, this module is hooking into progressbar class and checking for the "setIndeterminateDrawable" instruction. It then replaces the IndeterminteDrawable for the one customized by an user (right?). How do we set the indeterminate module and, at the same time, are able to replace it on different styles for an indeterminate progressbar?

As mentioned...I really could use some help to get this working.

Sorry for long post...