Skip to content

Commit e57c25f

Browse files
committed
Show Python version as subtitle in demo and pkgtest apps
1 parent 7c0f58d commit e57c25f

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

demo/app/src/utils/java/com/chaquo/python/utils/App.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.app.*;
44
import android.content.*;
55

6+
import androidx.appcompat.app.*;
67
import androidx.preference.*;
78

89
import com.chaquo.python.*;
@@ -28,4 +29,10 @@ public void onCreate() {
2829
Python.start(platform);
2930
}
3031

32+
public static void setPySubtitle(AppCompatActivity activity) {
33+
PyObject platform = Python.getInstance().getModule("platform");
34+
activity.getSupportActionBar().setSubtitle(
35+
"Python " + platform.callAttr("python_version").toString());
36+
}
37+
3138
}

demo/app/src/utils/java/com/chaquo/python/utils/ConsoleActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public static class ConsoleModel extends ViewModel {
4949
@Override
5050
protected void onCreate(Bundle savedInstanceState) {
5151
super.onCreate(savedInstanceState);
52+
App.setPySubtitle(this);
53+
5254
consoleModel = ViewModelProviders.of(this).get(ConsoleModel.class);
5355
task = ViewModelProviders.of(this).get(getTaskClass());
5456
setContentView(resId("layout", "activity_console"));

demo/app/src/utils/java/com/chaquo/python/utils/MainActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ protected void onCreate(Bundle savedInstanceState) {
1616
String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
1717
setTitle(getTitle() + " " + version);
1818
} catch (PackageManager.NameNotFoundException ignored) {}
19+
App.setPySubtitle(this);
1920

2021
setContentView(resId("layout", "activity_menu"));
2122
((TextView)findViewById(resId("id", "tvCaption")))

0 commit comments

Comments
 (0)