Skip to content

Commit

Permalink
Show Python version as subtitle in demo and pkgtest apps
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsmith committed Oct 17, 2024
1 parent 7c0f58d commit e57c25f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions demo/app/src/utils/java/com/chaquo/python/utils/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.*;
import android.content.*;

import androidx.appcompat.app.*;
import androidx.preference.*;

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

public static void setPySubtitle(AppCompatActivity activity) {
PyObject platform = Python.getInstance().getModule("platform");
activity.getSupportActionBar().setSubtitle(
"Python " + platform.callAttr("python_version").toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ public static class ConsoleModel extends ViewModel {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
App.setPySubtitle(this);

consoleModel = ViewModelProviders.of(this).get(ConsoleModel.class);
task = ViewModelProviders.of(this).get(getTaskClass());
setContentView(resId("layout", "activity_console"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ protected void onCreate(Bundle savedInstanceState) {
String version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
setTitle(getTitle() + " " + version);
} catch (PackageManager.NameNotFoundException ignored) {}
App.setPySubtitle(this);

setContentView(resId("layout", "activity_menu"));
((TextView)findViewById(resId("id", "tvCaption")))
Expand Down

0 comments on commit e57c25f

Please sign in to comment.