Android: simplify QtActivityBase.addReferrer() code

Making it easier to read following the conditions being
checked, and less temporary variables. Also, call it at
the end of onCreate() once all other operations are done.

Change-Id: Id16fb1a75ac5429e5132712a7824656ad16cbac1
Reviewed-by: Petri Virkkunen <petri.virkkunen@qt.io>
(cherry picked from commit 42790db73ee5dff1dbdf3a18a516d806be3fa0ab)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
bb10
Assam Boudjelthia 2024-10-25 14:11:06 +03:00 committed by Qt Cherry-pick Bot
parent 5d5f51d3e0
commit 3a25183c5d
1 changed files with 13 additions and 17 deletions

View File

@ -27,34 +27,31 @@ import java.lang.IllegalArgumentException;
public class QtActivityBase extends Activity
{
public static final String EXTRA_SOURCE_INFO = "org.qtproject.qt.android.sourceInfo";
private String m_applicationParams = "";
private boolean m_isCustomThemeSet = false;
private boolean m_retainNonConfigurationInstance = false;
private Configuration m_prevConfig;
private final QtActivityDelegate m_delegate;
public static final String EXTRA_SOURCE_INFO = "org.qtproject.qt.android.sourceInfo";
private void addReferrer(Intent intent)
{
if (intent.getExtras() != null && intent.getExtras().getString(EXTRA_SOURCE_INFO) != null)
Bundle extras = intent.getExtras();
if (extras != null && extras.getString(EXTRA_SOURCE_INFO) != null)
return;
String browserApplicationId = "";
if (intent.getExtras() != null)
browserApplicationId = intent.getExtras().getString(Browser.EXTRA_APPLICATION_ID);
String sourceInformation = "";
if (browserApplicationId != null && !browserApplicationId.isEmpty()) {
sourceInformation = browserApplicationId;
} else {
if (extras == null) {
Uri referrer = getReferrer();
if (referrer != null)
sourceInformation = referrer.toString().replaceFirst("android-app://", "");
if (referrer != null) {
String cleanReferrer = referrer.toString().replaceFirst("android-app://", "");
intent.putExtra(EXTRA_SOURCE_INFO, cleanReferrer);
}
} else {
String applicationId = extras.getString(Browser.EXTRA_APPLICATION_ID);
if (applicationId != null)
intent.putExtra(EXTRA_SOURCE_INFO, applicationId);
}
intent.putExtra(EXTRA_SOURCE_INFO, sourceInformation);
}
// Append any parameters to your application.
@ -108,7 +105,6 @@ public class QtActivityBase extends Activity
}
QtNative.registerAppStateListener(m_delegate);
addReferrer(getIntent());
try {