2022-10-02 23:06:56 +02:00
package android.app ;
2023-08-17 10:46:24 +02:00
import android.R ;
2023-09-01 12:34:57 +02:00
import android.content.BroadcastReceiver ;
2022-10-02 23:06:56 +02:00
import android.content.ComponentName ;
2024-06-15 22:32:01 +02:00
import android.content.Context ;
2022-10-02 23:06:56 +02:00
import android.content.Intent ;
2024-04-12 18:32:30 +02:00
import android.content.SharedPreferences ;
2024-06-10 23:24:29 +02:00
import android.content.pm.PackageParser ;
2022-11-04 19:21:45 +01:00
import android.content.res.Configuration ;
2024-10-23 16:35:58 +02:00
import android.content.res.TypedArray ;
import android.graphics.drawable.Drawable ;
2024-03-16 18:14:46 +01:00
import android.net.Uri ;
2022-10-02 23:06:56 +02:00
import android.os.Bundle ;
2023-07-25 14:26:29 +02:00
import android.os.Handler ;
import android.os.Looper ;
2025-01-11 17:47:49 +01:00
import android.util.AttributeSet ;
2024-11-30 18:49:11 +01:00
import android.util.Slog ;
2024-06-15 22:32:01 +02:00
import android.view.ContextThemeWrapper ;
2023-06-22 11:45:46 +02:00
import android.view.LayoutInflater ;
2023-09-01 12:34:57 +02:00
import android.view.Menu ;
import android.view.MenuInflater ;
import android.view.MenuItem ;
2022-10-02 23:06:56 +02:00
import android.view.View ;
2023-06-18 11:03:43 +02:00
import android.view.ViewGroup ;
2022-10-02 23:06:56 +02:00
import android.view.Window ;
import android.view.WindowManager ;
import android.view.WindowManagerImpl ;
2024-05-22 23:38:54 +02:00
2025-03-25 19:15:36 +01:00
import java.io.IOException ;
2023-05-20 19:23:40 +02:00
import java.lang.reflect.Constructor ;
import java.lang.reflect.InvocationTargetException ;
2023-08-22 13:29:44 +02:00
import java.util.ArrayList ;
2024-03-16 18:14:46 +01:00
import java.util.Arrays ;
2024-06-24 18:44:31 +02:00
import java.util.HashMap ;
2023-08-22 13:29:44 +02:00
import java.util.List ;
2024-06-24 18:44:31 +02:00
import java.util.Map ;
2022-10-02 23:06:56 +02:00
2025-01-11 17:47:49 +01:00
public class Activity extends ContextThemeWrapper implements Window . Callback , LayoutInflater . Factory2 {
2024-11-30 18:49:11 +01:00
private final static String TAG = " Activity " ;
public static final int RESULT_CANCELED = 0 ;
public static final int RESULT_OK = - 1 ;
2024-08-25 11:20:01 +02:00
Window window = new Window ( this , this ) ;
2022-10-26 18:39:04 +02:00
int requested_orientation = - 1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/ ; // dummy
2023-09-19 23:09:58 +02:00
public Intent intent ;
2023-08-22 13:23:34 +02:00
private Activity resultActivity ;
private int resultRequestCode ;
2024-03-05 17:07:21 +01:00
private boolean paused = false ;
2024-04-07 21:33:32 +02:00
private CharSequence title = null ;
2023-08-22 13:29:44 +02:00
List < Fragment > fragments = new ArrayList < > ( ) ;
2024-06-13 21:00:06 +02:00
boolean destroyed = false ;
2022-10-02 23:06:56 +02:00
2024-12-13 16:25:07 +01:00
public static Activity internalCreateActivity ( String className , long native_window , Intent intent ) throws ReflectiveOperationException {
int themeResId = 0 ;
CharSequence label = null ;
CharSequence app_label = null ;
for ( PackageParser . Activity activity : pkg . activities ) {
if ( className . equals ( activity . className ) ) {
label = r . getText ( activity . info . labelRes ) ;
themeResId = activity . info . getThemeResource ( ) ;
break ;
}
}
Class < ? extends Activity > cls = Class . forName ( className ) . asSubclass ( Activity . class ) ;
Constructor < ? extends Activity > constructor = cls . getConstructor ( ) ;
Activity activity = constructor . newInstance ( ) ;
activity . window . native_window = native_window ;
activity . intent = intent ;
activity . attachBaseContext ( new Context ( ) ) ;
activity . setTheme ( themeResId ) ;
app_label = r . getText ( pkg . applicationInfo . labelRes ) ;
if ( label ! = null ) {
activity . setTitle ( label ) ;
} else if ( app_label ! = null ) {
activity . setTitle ( app_label ) ;
}
return activity ;
}
2023-05-20 19:23:40 +02:00
/ * *
* Helper function to be called from native code to construct main activity
*
* @param className class name of activity or null
* @return instance of main activity class
2025-02-05 16:27:17 +01:00
* @throws Exception
2023-05-20 19:23:40 +02:00
* /
2024-10-05 22:12:14 +02:00
private static Activity createMainActivity ( String className , long native_window , String uriString ) throws Exception {
Uri uri = uriString ! = null ? Uri . parse ( uriString ) : null ;
2023-05-20 19:23:40 +02:00
if ( className = = null ) {
2024-06-10 23:24:29 +02:00
for ( PackageParser . Activity activity : pkg . activities ) {
2025-03-25 18:49:36 +01:00
boolean isDefault = false ;
2024-06-10 23:24:29 +02:00
for ( PackageParser . IntentInfo intent : activity . intents ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , intent . toString ( ) ) ;
2024-10-05 22:12:14 +02:00
if ( ( uri = = null & & intent . hasCategory ( " android.intent.category.LAUNCHER " ) ) | |
( uri ! = null & & intent . hasDataScheme ( uri . getScheme ( ) ) ) ) {
2024-06-10 23:24:29 +02:00
className = activity . className ;
2025-03-25 18:49:36 +01:00
isDefault = intent . hasCategory ( " android.intent.category.DEFAULT " ) ;
if ( isDefault )
break ;
2024-05-22 23:38:54 +02:00
}
}
2025-03-25 18:49:36 +01:00
if ( isDefault )
2024-06-10 23:24:29 +02:00
break ;
2024-05-22 23:38:54 +02:00
}
2023-05-20 19:23:40 +02:00
} else {
className = className . replace ( '/' , '.' ) ;
}
2024-10-05 22:12:14 +02:00
if ( className = = null ) {
System . err . println ( " Failed to find Activity to launch URI: " + uri ) ;
System . exit ( 1 ) ;
}
2024-12-13 16:25:07 +01:00
return internalCreateActivity ( className , native_window , uri ! = null ? new Intent ( " android.intent.action.VIEW " , uri ) : new Intent ( ) ) ;
2022-10-02 23:06:56 +02:00
}
public Activity ( ) {
2024-02-10 20:37:28 +01:00
super ( null ) ;
2022-10-02 23:06:56 +02:00
}
public View root_view ;
2023-06-22 11:45:46 +02:00
public final Application getApplication ( ) {
2022-10-02 23:06:56 +02:00
return ( Application ) getApplicationContext ( ) ;
}
public WindowManager getWindowManager ( ) {
return new WindowManagerImpl ( ) ;
}
2022-12-31 16:59:15 +01:00
public String getCallingPackage ( ) {
return null ; // [from api reference] Note: if the calling activity is not expecting a result (that is it did not use the startActivityForResult(Intent, int) form that includes a request code), then the calling package will be null.
}
2022-10-02 23:06:56 +02:00
public ComponentName getComponentName ( ) {
return null ;
}
public Intent getIntent ( ) {
2023-08-11 18:09:17 +02:00
return intent ;
2022-10-02 23:06:56 +02:00
}
2022-10-26 18:39:04 +02:00
public int getRequestedOrientation ( ) {
2023-06-22 11:45:46 +02:00
return requested_orientation ;
2022-10-26 18:39:04 +02:00
}
2023-06-22 11:45:46 +02:00
public void setRequestedOrientation ( int orientation ) {
2022-10-26 18:39:04 +02:00
requested_orientation = orientation ;
}
2022-10-02 23:06:56 +02:00
public boolean isFinishing ( ) {
return false ; // FIXME
}
public final boolean requestWindowFeature ( int featureId ) {
return false ; // whatever feature it is, it's probably not supported
}
public final void setVolumeControlStream ( int streamType ) { }
protected void onCreate ( Bundle savedInstanceState ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onCreate - yay! " ) ;
2022-10-02 23:06:56 +02:00
2023-08-22 13:29:44 +02:00
for ( Fragment fragment : fragments ) {
fragment . onCreate ( savedInstanceState ) ;
}
2022-10-02 23:06:56 +02:00
return ;
}
2024-10-05 16:52:53 +02:00
protected void onPostCreate ( Bundle savedInstanceState ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onPostCreate - yay! " ) ;
2024-10-05 16:52:53 +02:00
return ;
}
2022-10-02 23:06:56 +02:00
protected void onStart ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onStart - yay! " ) ;
2024-12-11 21:42:22 +01:00
window . set_widget_as_root ( window . native_window , window . getDecorView ( ) . widget ) ;
2024-11-03 08:26:11 +01:00
window . setTitle ( title ) ;
2022-10-02 23:06:56 +02:00
2023-08-22 13:29:44 +02:00
for ( Fragment fragment : fragments ) {
fragment . onStart ( ) ;
}
2024-10-23 16:35:58 +02:00
TypedArray ta = obtainStyledAttributes ( new int [ ] { R . attr . windowBackground } ) ;
2025-02-10 17:56:45 +01:00
try {
Drawable background = ta . getDrawable ( 0 ) ;
if ( background ! = null )
window . setBackgroundDrawable ( background ) ;
} catch ( Exception e ) {
Slog . e ( TAG , " Error setting window background " , e ) ;
}
2024-10-23 16:35:58 +02:00
ta . recycle ( ) ;
2022-10-02 23:06:56 +02:00
return ;
}
protected void onRestart ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onRestart - yay! " ) ;
2022-10-02 23:06:56 +02:00
return ;
}
protected void onResume ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onResume - yay! " ) ;
2022-10-02 23:06:56 +02:00
2023-08-22 13:29:44 +02:00
for ( Fragment fragment : fragments ) {
fragment . onResume ( ) ;
}
2024-03-05 17:07:21 +01:00
paused = false ;
2022-10-02 23:06:56 +02:00
return ;
}
2024-10-05 16:52:53 +02:00
protected void onPostResume ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onPostResume - yay! " ) ;
2024-10-05 16:52:53 +02:00
return ;
}
2022-10-02 23:06:56 +02:00
protected void onPause ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onPause - yay! " ) ;
2022-10-02 23:06:56 +02:00
2023-08-22 13:29:44 +02:00
for ( Fragment fragment : fragments ) {
fragment . onPause ( ) ;
}
2024-03-05 17:07:21 +01:00
paused = true ;
2022-10-02 23:06:56 +02:00
return ;
}
protected void onStop ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onStop - yay! " ) ;
2022-10-02 23:06:56 +02:00
2023-08-22 13:29:44 +02:00
for ( Fragment fragment : fragments ) {
fragment . onStop ( ) ;
}
2022-10-02 23:06:56 +02:00
return ;
}
protected void onDestroy ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onDestroy - yay! " ) ;
2022-10-02 23:06:56 +02:00
2023-08-22 13:29:44 +02:00
for ( Fragment fragment : fragments ) {
fragment . onDestroy ( ) ;
}
2024-06-13 21:00:06 +02:00
destroyed = true ;
2022-10-02 23:06:56 +02:00
return ;
}
public void onWindowFocusChanged ( boolean hasFocus ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onWindowFocusChanged - yay! (hasFocus: " + hasFocus + " ) " ) ;
2022-10-02 23:06:56 +02:00
return ;
}
2022-11-04 19:21:45 +01:00
protected void onSaveInstanceState ( Bundle outState ) {
}
void onConfigurationChanged ( Configuration newConfig ) {
}
public void onLowMemory ( ) {
}
2022-10-02 23:06:56 +02:00
/* --- */
2023-06-22 11:45:46 +02:00
public void setContentView ( int layoutResID ) throws Exception {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - setContentView - yay! " ) ;
2022-10-02 23:06:56 +02:00
2024-12-13 16:25:07 +01:00
root_view = getLayoutInflater ( ) . inflate ( layoutResID , null , false ) ;
2022-10-02 23:06:56 +02:00
2024-09-27 15:11:00 +02:00
window . setContentView ( root_view ) ;
onContentChanged ( ) ;
2023-06-22 11:45:46 +02:00
}
2022-10-02 23:06:56 +02:00
2023-06-18 11:03:43 +02:00
public void setContentView ( View view , ViewGroup . LayoutParams layoutParams ) {
setContentView ( view ) ;
}
2022-10-02 23:06:56 +02:00
public void setContentView ( View view ) {
window . setContentView ( view ) ;
2024-03-07 15:44:21 +01:00
onContentChanged ( ) ;
2022-10-02 23:06:56 +02:00
}
public < T extends android . view . View > T findViewById ( int id ) {
2024-12-11 21:42:22 +01:00
View view = window . findViewById ( id ) ;
2022-10-02 23:06:56 +02:00
2023-06-22 11:45:46 +02:00
return ( T ) view ;
2022-10-02 23:06:56 +02:00
}
public void invalidateOptionsMenu ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " invalidateOptionsMenu() called, should we do something? " ) ;
2022-10-02 23:06:56 +02:00
}
public Window getWindow ( ) {
return this . window ;
}
2023-06-22 11:45:46 +02:00
public final void runOnUiThread ( Runnable action ) {
2023-07-25 14:26:29 +02:00
if ( Looper . myLooper ( ) = = Looper . getMainLooper ( ) ) {
action . run ( ) ;
} else {
new Handler ( Looper . getMainLooper ( ) ) . post ( action ) ;
}
2023-06-22 11:45:46 +02:00
}
2023-01-09 12:08:23 +01:00
2023-06-22 11:45:46 +02:00
protected void onActivityResult ( int requestCode , int resultCode , Intent data ) { }
2023-01-09 12:08:23 +01:00
2024-03-16 18:14:46 +01:00
// the order must match GtkFileChooserAction enum
private static final List < String > FILE_CHOOSER_ACTIONS = Arrays . asList (
" android.intent.action.OPEN_DOCUMENT " , // (0) GTK_FILE_CHOOSER_ACTION_OPEN
" android.intent.action.CREATE_DOCUMENT " , // (1) GTK_FILE_CHOOSER_ACTION_SAVE
" android.intent.action.OPEN_DOCUMENT_TREE " // (2) GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER
) ;
// callback from native code
protected void fileChooserResultCallback ( int requestCode , int resultCode , int action , String uri ) {
onActivityResult ( requestCode , resultCode , new Intent ( FILE_CHOOSER_ACTIONS . get ( action ) , uri ! = null ? Uri . parse ( uri ) : null ) ) ;
}
2024-03-16 12:49:28 +01:00
public void startActivityForResult ( Intent intent , int requestCode , Bundle options ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " startActivityForResult( " + intent + " , " + requestCode + " , " + options + " ) called " ) ;
2023-08-11 18:09:17 +02:00
if ( intent . getComponent ( ) ! = null ) {
try {
2025-01-11 17:44:35 +01:00
final Activity activity = internalCreateActivity ( intent . getComponent ( ) . getClassName ( ) , getWindow ( ) . native_window , intent ) ;
2023-08-22 13:23:34 +02:00
activity . resultRequestCode = requestCode ;
activity . resultActivity = this ;
2024-03-05 17:07:21 +01:00
runOnUiThread ( new Runnable ( ) {
@Override
public void run ( ) {
nativeStartActivity ( activity ) ;
}
} ) ;
2025-01-11 17:44:35 +01:00
} catch ( ReflectiveOperationException e ) {
2024-03-16 18:14:46 +01:00
onActivityResult ( requestCode , 0 /*RESULT_CANCELED*/ , new Intent ( ) ) ;
2023-08-11 18:09:17 +02:00
}
2024-03-16 18:14:46 +01:00
} else if ( FILE_CHOOSER_ACTIONS . contains ( intent . getAction ( ) ) ) {
nativeFileChooser ( FILE_CHOOSER_ACTIONS . indexOf ( intent . getAction ( ) ) , intent . getType ( ) , intent . getStringExtra ( " android.intent.extra.TITLE " ) , requestCode ) ;
2025-03-25 19:15:36 +01:00
} else if ( " android.intent.action.INSTALL_PACKAGE " . equals ( intent . getAction ( ) ) ) {
try {
Process p = new ProcessBuilder ( " /usr/bin/env " , " android-translation-layer " , " --install " , intent . getData ( ) . getPath ( ) ) . start ( ) ;
int exitValue = p . waitFor ( ) ;
if ( exitValue = = 0 ) {
onActivityResult ( requestCode , - 1 /*RESULT_OK*/ , new Intent ( ) ) ;
} else {
onActivityResult ( requestCode , 0 /*RESULT_CANCELED*/ , new Intent ( ) ) ;
}
} catch ( IOException | InterruptedException e ) {
e . printStackTrace ( ) ;
onActivityResult ( requestCode , 0 /*RESULT_CANCELED*/ , new Intent ( ) ) ;
}
2024-11-30 18:49:11 +01:00
} else {
Slog . i ( TAG , " startActivityForResult: intent was not handled. Calling onActivityResult(RESULT_CANCELED). " ) ;
2024-03-16 18:14:46 +01:00
onActivityResult ( requestCode , 0 /*RESULT_CANCELED*/ , new Intent ( ) ) ;
2023-08-11 18:09:17 +02:00
}
}
2024-03-16 12:49:28 +01:00
public void startActivityForResult ( Intent intent , int requestCode ) {
startActivityForResult ( intent , requestCode , null ) ;
}
2023-08-11 18:09:17 +02:00
2023-08-22 13:23:34 +02:00
public void setResult ( int resultCode , Intent data ) {
if ( resultActivity ! = null ) {
2024-08-29 13:43:47 +02:00
resultActivity . onActivityResult ( resultRequestCode , resultCode , data ) ;
2023-08-22 13:23:34 +02:00
}
}
2023-09-01 12:55:04 +02:00
public void setResult ( int resultCode ) {
setResult ( resultCode , null ) ;
}
2024-06-24 18:44:31 +02:00
protected Dialog onCreateDialog ( int id ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " Activity.onCreateDialog( " + id + " ) called " ) ;
2024-06-24 18:44:31 +02:00
return null ;
}
protected void onPrepareDialog ( int id , Dialog dialog ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " Activity.onPrepareDialog( " + id + " ) called " ) ;
2024-06-24 18:44:31 +02:00
}
private Map < Integer , Dialog > dialogs = new HashMap < Integer , Dialog > ( ) ;
2023-07-25 14:29:43 +02:00
public final void showDialog ( int id ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " Activity.showDialog( " + id + " ) called " ) ;
2024-06-24 18:44:31 +02:00
Dialog dialog = dialogs . get ( id ) ;
if ( dialog = = null )
dialogs . put ( id , dialog = onCreateDialog ( id ) ) ;
onPrepareDialog ( id , dialog ) ;
dialog . show ( ) ;
}
2024-11-22 18:02:54 +01:00
public boolean showDialog ( int id , Bundle args ) {
return false ;
}
2024-06-24 18:44:31 +02:00
public void removeDialog ( int id ) {
Dialog dialog = dialogs . remove ( id ) ;
if ( dialog ! = null )
dialog . dismiss ( ) ;
2023-07-25 14:29:43 +02:00
}
2023-08-11 18:09:17 +02:00
public void finish ( ) {
2024-03-05 17:07:21 +01:00
runOnUiThread ( new Runnable ( ) {
@Override
public void run ( ) {
2024-11-22 18:02:54 +01:00
if ( window ! = null & & window . native_window ! = 0 ) {
2024-08-25 11:20:01 +02:00
nativeFinish ( getWindow ( ) . native_window ) ;
2024-11-22 18:02:54 +01:00
window . native_window = 0 ;
2024-08-25 11:20:01 +02:00
}
2024-03-05 17:07:21 +01:00
}
} ) ;
2023-08-11 18:09:17 +02:00
}
2023-08-17 10:46:24 +02:00
public Object getLastNonConfigurationInstance ( ) {
return null ;
}
public FragmentManager getFragmentManager ( ) {
2023-08-22 13:29:44 +02:00
return new FragmentManager ( this ) ;
2023-08-17 10:46:24 +02:00
}
public LayoutInflater getLayoutInflater ( ) {
2025-01-27 18:16:25 +01:00
return ( LayoutInflater ) getSystemService ( " layout_inflater " ) ;
2023-08-17 10:46:24 +02:00
}
2023-08-22 14:41:01 +02:00
public boolean isChangingConfigurations ( ) { return false ; }
2023-09-01 12:34:57 +02:00
@Override
public void onContentChanged ( ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " - onContentChanged - yay! " ) ;
2023-09-01 12:34:57 +02:00
}
public boolean onCreateOptionsMenu ( Menu menu ) {
return true ;
}
@Override
public boolean onCreatePanelMenu ( int featureId , Menu menu ) {
if ( featureId = = Window . FEATURE_OPTIONS_PANEL ) {
2025-02-18 18:56:19 +01:00
// HACK: catch non critical error occuring in Open Sudoku app
try {
return onCreateOptionsMenu ( menu ) ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
return false ;
}
2023-09-01 12:34:57 +02:00
}
return false ;
}
@Override
public View onCreatePanelView ( int featureId ) {
return null ;
}
public MenuInflater getMenuInflater ( ) {
return new MenuInflater ( this ) ;
}
public boolean onPrepareOptionsMenu ( Menu menu ) {
return true ;
}
@Override
public boolean onPreparePanel ( int featureId , View view , Menu menu ) {
if ( featureId = = Window . FEATURE_OPTIONS_PANEL & & menu ! = null ) {
return onPrepareOptionsMenu ( menu ) ;
}
return true ;
}
@Override
public boolean onMenuItemSelected ( int featureId , MenuItem item ) {
if ( featureId = = Window . FEATURE_OPTIONS_PANEL ) {
return onOptionsItemSelected ( item ) ;
}
return false ;
}
public boolean onOptionsItemSelected ( MenuItem item ) {
return false ;
}
public void onOptionsMenuClosed ( Menu menu ) { }
@Override
public void onPanelClosed ( int featureId , Menu menu ) {
if ( featureId = = Window . FEATURE_OPTIONS_PANEL ) {
onOptionsMenuClosed ( menu ) ;
}
}
2023-09-01 12:55:04 +02:00
2024-04-07 21:33:32 +02:00
public void setTitle ( CharSequence title ) {
this . title = title ;
}
2024-06-15 22:32:01 +02:00
public void setTitle ( int titleId ) {
this . title = getText ( titleId ) ;
}
2024-04-07 21:33:32 +02:00
public CharSequence getTitle ( ) {
return title ;
}
2023-09-01 12:55:04 +02:00
public void onBackPressed ( ) {
2024-11-15 08:15:04 +01:00
System . out . println ( " onBackPressed() called " ) ;
2023-09-01 12:55:04 +02:00
finish ( ) ;
}
2024-10-05 22:12:14 +02:00
public void setIntent ( Intent newIntent ) {
this . intent = newIntent ;
}
2023-10-29 22:47:57 +01:00
2023-09-01 12:55:04 +02:00
public void unregisterReceiver ( BroadcastReceiver receiver ) { }
2024-02-10 20:37:28 +01:00
2024-02-15 21:09:47 +01:00
public Intent getParentActivityIntent ( ) {
return null ;
}
2024-02-17 15:15:05 +01:00
@Override
public boolean onMenuOpened ( int featureId , Menu menu ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " onMenuOpened( " + featureId + " , " + menu + " ) called " ) ;
2024-02-17 15:15:05 +01:00
return false ;
}
2024-02-19 16:29:09 +01:00
public void recreate ( ) {
try {
/* TODO: check if this is a toplevel activity */
2024-12-13 16:25:07 +01:00
Activity activity = internalCreateActivity ( this . getClass ( ) . getName ( ) , getWindow ( ) . native_window , intent ) ;
2024-02-19 16:29:09 +01:00
nativeFinish ( 0 ) ;
2024-10-06 08:07:59 +02:00
nativeStartActivity ( activity ) ;
2024-12-13 16:25:07 +01:00
} catch ( ReflectiveOperationException e ) {
2024-11-30 18:49:11 +01:00
Slog . i ( TAG , " exception in Activity.recreate, this is kinda sus " ) ;
2024-02-19 16:29:09 +01:00
e . printStackTrace ( ) ;
}
}
2024-04-12 18:32:30 +02:00
public String getLocalClassName ( ) {
final String pkg = getPackageName ( ) ;
final String cls = this . getClass ( ) . getName ( ) ;
int packageLen = pkg . length ( ) ;
if ( ! cls . startsWith ( pkg ) | | cls . length ( ) < = packageLen | | cls . charAt ( packageLen ) ! = '.' ) {
return cls ;
}
return cls . substring ( packageLen + 1 ) ;
}
public SharedPreferences getPreferences ( int mode ) {
return getSharedPreferences ( getLocalClassName ( ) , mode ) ;
}
2024-04-26 14:49:37 +02:00
protected void onNewIntent ( Intent intent ) { }
public final Activity getParent ( ) {
return null ;
}
public boolean hasWindowFocus ( ) {
return true ; // FIXME?
}
2024-06-13 21:00:06 +02:00
public boolean isDestroyed ( ) {
return destroyed ;
}
2024-06-15 22:32:01 +02:00
public void finishAffinity ( ) {
finish ( ) ;
}
2024-06-24 18:44:31 +02:00
public void overridePendingTransition ( int enterAnim , int exitAnim ) { }
2024-08-25 11:20:01 +02:00
public boolean isTaskRoot ( ) {
return false ;
}
public void postponeEnterTransition ( ) { }
public void startPostponedEnterTransition ( ) { }
2024-09-03 17:49:56 +02:00
public boolean isChild ( ) {
return false ;
}
2024-10-04 16:15:44 +02:00
public void setTaskDescription ( ActivityManager . TaskDescription description ) { }
2024-02-10 20:37:28 +01:00
private native void nativeFinish ( long native_window ) ;
public static native void nativeStartActivity ( Activity activity ) ;
public static native void nativeOpenURI ( String uri ) ;
2024-03-16 18:14:46 +01:00
public native void nativeFileChooser ( int action , String type , String title , int requestCode ) ;
2024-10-12 14:53:30 +03:00
public void reportFullyDrawn ( ) { }
2024-11-01 14:21:15 +01:00
public void setVisible ( boolean visible ) { }
public Uri getReferrer ( ) { return null ; }
2024-11-07 18:31:27 +01:00
public void setDefaultKeyMode ( int flag ) { }
public void registerForContextMenu ( View view ) { }
2024-12-20 17:32:53 +01:00
public native boolean isInMultiWindowMode ( ) ;
2024-10-28 19:06:17 +01:00
public void registerActivityLifecycleCallbacks ( Application . ActivityLifecycleCallbacks callback ) { }
public void setDisablePreviewScreenshots ( boolean disable ) { }
public final View requireViewById ( int id ) {
View view = findViewById ( id ) ;
if ( view = = null )
throw new IllegalArgumentException ( " ID does not reference a View inside this View " ) ;
return view ;
}
2025-01-11 17:47:49 +01:00
public View onCreateView ( View parent , String name , Context context , AttributeSet attrs ) {
return null ;
}
2025-01-11 18:01:43 +01:00
public boolean onSearchRequested ( ) {
return false ;
}
public View getCurrentFocus ( ) {
return null ;
}
2025-01-12 10:42:51 +01:00
public void setProgressBarIndeterminateVisibility ( boolean indeterminate ) { }
public int getChangingConfigurations ( ) {
return 0 ;
}
2022-10-02 23:06:56 +02:00
}