I am using a Google library called play-services-plugins to include Open Source Notices on my app.
I could implement it with no problem, but I have no idea how I can style the activity that displays the license.
In my code, I start the activity by calling startActivity(Intent(this, OssLicensesMenuActivity::class.java))
Since OssLicensesMenuActivity
is an Activity class, I manage to style like this:
styles.xml:
<style name="LicensesTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimaryDark</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
AndroidManifest.xml:
<activity
android:name="com.google.android.gms.oss.licenses.OssLicensesMenuActivity"
android:theme="@style/LicensesTheme" />
This works like a charm, but this activity just displays all the libraries I'm using.
There is a second activity that displays the licence and that's the one I can't figure out how to style. The problem I'm facing is that the code from OssLicensesMenuActivity
is obfuscated and I can't find the name and package of the activity class I want to style.
Anyone knows how I can solve this problem?
Just to it's easier to check, the obfuscated code from OssLicensesMenuActivity
is the following:
package com.google.android.gms.oss.licenses;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.content.res.XmlResourceParser;
import android.content.res.Resources.NotFoundException;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.app.AppCompatActivity;
import androidx.loader.app.LoaderManager.LoaderCallbacks;
import androidx.loader.content.Loader;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.internal.oss_licenses.zzc;
import com.google.android.gms.oss.licenses.R.id;
import com.google.android.gms.oss.licenses.R.layout;
import com.google.android.gms.tasks.Task;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
public final class OssLicensesMenuActivity extends AppCompatActivity implements LoaderCallbacks<List<zzc>> {
private static String zzx;
private ListView zzy;
private ArrayAdapter<zzc> zzz;
private boolean zzaa;
private zze zzp;
private Task<String> zzab;
private com.google.android.gms.oss.licenses.zzc zzo;
public OssLicensesMenuActivity() {
}
@KeepForSdk
protected final void onCreate(@Nullable Bundle var1) {
super.onCreate(var1);
this.zzo = com.google.android.gms.oss.licenses.zzc.zza(this);
this.zzaa = fileExistsAndNotEmpty(this, "third_party_licenses") && fileExistsAndNotEmpty(this, "third_party_license_metadata");
Intent var3;
if (zzx == null && (var3 = this.getIntent()).hasExtra("title")) {
zzx = var3.getStringExtra("title");
Log.w("OssLicensesMenuActivity", "The intent based title is deprecated. Use OssLicensesMenuActivity.setActivityTitle(title) instead.");
}
if (zzx != null) {
this.setTitle(zzx);
}
if (this.getSupportActionBar() != null) {
this.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
if (this.zzaa) {
zzh var10001 = com.google.android.gms.oss.licenses.zzc.zza(this).zzb();
String var4 = this.getPackageName();
zzh var2 = var10001;
this.zzab = var10001.doRead(new zzk(var2, var4));
this.getSupportLoaderManager().initLoader(54321, (Bundle)null, this);
this.zzab.addOnCompleteListener(new zzp(this));
} else {
this.setContentView(layout.license_menu_activity_no_licenses);
}
}
public static void setActivityTitle(@NonNull String var0) {
zzx = var0;
}
@VisibleForTesting(
otherwise = 2
)
@KeepForSdk
static boolean fileExistsAndNotEmpty(@NonNull Context var0, @NonNull String var1) {
InputStream var2 = null;
try {
Resources var3;
String var4 = (var3 = var0.getResources()).getResourcePackageName(id.license_list);
boolean var5 = (var2 = var3.openRawResource(var3.getIdentifier(var1, "raw", var4))).available() > 0;
return var5;
} catch (IOException | NotFoundException var13) {
} finally {
if (var2 != null) {
try {
var2.close();
} catch (IOException var12) {
}
}
}
return false;
}
@KeepForSdk
public final boolean onOptionsItemSelected(MenuItem var1) {
if (var1.getItemId() == 16908332) {
this.finish();
return true;
} else {
return super.onOptionsItemSelected(var1);
}
}
@KeepForSdk
public final void onDestroy() {
this.getSupportLoaderManager().destroyLoader(54321);
super.onDestroy();
}
@KeepForSdk
public final Loader<List<zzc>> onCreateLoader(int var1, Bundle var2) {
return this.zzaa ? new zzo(this, com.google.android.gms.oss.licenses.zzc.zza(this)) : null;
}
@KeepForSdk
public final void onLoadFinished(Loader<List<zzc>> var1, List<zzc> var2) {
this.zzz.clear();
this.zzz.addAll(var2);
this.zzz.notifyDataSetChanged();
}
@KeepForSdk
public final void onLoaderReset(Loader<List<zzc>> var1) {
this.zzz.clear();
this.zzz.notifyDataSetChanged();
}
private class zza extends ArrayAdapter<zzc> {
zza(Context var2) {
OssLicensesMenuActivity.this.zzo;
int var10002 = com.google.android.gms.oss.licenses.zzc.zza(OssLicensesMenuActivity.this.zzp);
OssLicensesMenuActivity.this.zzo;
super(var2, var10002, com.google.android.gms.oss.licenses.zzc.zzb(OssLicensesMenuActivity.this.zzp), new ArrayList());
}
public final View getView(int var1, View var2, ViewGroup var3) {
if (var2 == null) {
OssLicensesMenuActivity.this.zzo;
LayoutInflater var10000 = OssLicensesMenuActivity.this.getLayoutInflater();
zze var6 = OssLicensesMenuActivity.this.zzp;
LayoutInflater var4 = var10000;
XmlResourceParser var7 = var6.zzg.getXml(com.google.android.gms.oss.licenses.zzc.zza(var6));
var2 = var4.inflate(var7, var3, false);
}
OssLicensesMenuActivity.this.zzo;
((TextView)var2.findViewById(com.google.android.gms.oss.licenses.zzc.zzb(OssLicensesMenuActivity.this.zzp))).setText(((zzc)this.getItem(var1)).toString());
return var2;
}
}
}
Click on each item of the list would invoke OssLicensesActivity to show the actual content of the license. Sets the title for OssLicensesMenuActivity .
The content section of a styling rule defines the application of the styling rule on the table. We can define the relevant context for the styling rule. Using the mouse button on the right top corner, we can pick and select the desired context in the table widget itself.
The following Design Tokens can be used to configure components stylistically. The most common need for setting a token is to switch between light and dark mode. baseLayerLuminance: Set to StandardLuminance.DarkMode to switch into dark mode.
The Fluent UI Web Components are designed to be stylistically flexible, allowing dramatic changes to visual design with minimal code changes. This is possible through the extensive use of Design Tokens and an adaptive color system. The following Design Tokens can be used to configure components stylistically.
Just do the same for "OssLicensesActivity" as you did for "OssLicensesMenuActivity" in the Manifest:
<activity android:name="com.google.android.gms.oss.licenses.OssLicensesActivity"
android:theme="@style/LicensesTheme" />
This should style the "second activity that displays the licence".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With