-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/github/ma1co/openmemories/tweak/BackupInfoAdapter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.github.ma1co.openmemories.tweak; | ||
|
||
public class BackupInfoAdapter<T> implements ItemActivity.InfoItem.Adapter { | ||
private final BackupProperty<T> property; | ||
|
||
public BackupInfoAdapter(BackupProperty<T> property) { | ||
this.property = property; | ||
} | ||
|
||
public BackupProperty<T> getProperty() { | ||
return property; | ||
} | ||
|
||
@Override | ||
public boolean isAvailable() { | ||
return property.exists(); | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
try { | ||
return property.getValue().toString(); | ||
} catch (BackupProperty.BackupException e) { | ||
return ""; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
app/src/main/java/com/github/ma1co/openmemories/tweak/InfoActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.github.ma1co.openmemories.tweak; | ||
|
||
import android.os.Bundle; | ||
|
||
import java.io.IOException; | ||
|
||
public class InfoActivity extends ItemActivity { | ||
public static class LoggingInfoAdapter implements InfoItem.Adapter { | ||
private final String key; | ||
private final InfoItem.Adapter parent; | ||
|
||
public LoggingInfoAdapter(String key, InfoItem.Adapter parent) { | ||
this.key = key; | ||
this.parent = parent; | ||
} | ||
|
||
@Override | ||
public boolean isAvailable() { | ||
return parent.isAvailable(); | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
String value = parent.getValue(); | ||
Logger.info("InfoAdapter", String.format("%s: %s", key, value)); | ||
return value; | ||
} | ||
} | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
|
||
addLoggedInfo("Model", new BackupInfoAdapter<>(BackupKeys.MODEL_NAME)); | ||
|
||
addInfo("Serial number", new BackupInfoAdapter<byte[]>(BackupKeys.SERIAL_NUMBER) { | ||
@Override | ||
public String getValue() { | ||
try { | ||
byte[] serial = getProperty().getValue(); | ||
return String.format("%x%02x%02x%02x", serial[0], serial[1], serial[2], serial[3]); | ||
} catch (BackupProperty.BackupException e) { | ||
return ""; | ||
} | ||
} | ||
}); | ||
|
||
addLoggedInfo("Backup region", new InfoItem.Adapter() { | ||
@Override | ||
public boolean isAvailable() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
try { | ||
return Backup.readData().getRegion(); | ||
} catch (IOException | NativeException e) { | ||
return ""; | ||
} | ||
} | ||
}); | ||
|
||
addLoggedInfo("Tweak app version", new InfoItem.Adapter() { | ||
@Override | ||
public boolean isAvailable() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getValue() { | ||
return BuildConfig.VERSION_NAME; | ||
} | ||
}); | ||
|
||
addLoggedInfo("Java API version", new BackupInfoAdapter<>(BackupKeys.PLATFORM_VERSION)); | ||
} | ||
|
||
protected BaseItem addLoggedInfo(String title, InfoItem.Adapter adapter) { | ||
return addInfo(title, new LoggingInfoAdapter(title, adapter)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<merge xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:textStyle="bold" | ||
android:id="@+id/title"/> | ||
<TextView | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_below="@id/title" | ||
android:id="@+id/value"/> | ||
</merge> |