1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-03 03:30:06 +00:00

Replace android code which are not available on older android versions

This commit is contained in:
hogliux 2016-02-02 12:59:04 +00:00
parent f72bd28ea5
commit 2e0325c5df

View file

@ -133,7 +133,7 @@ public class JuceAppActivity extends Activity
super.onCreate (savedInstanceState);
isScreenSaverEnabled = true;
getActionBar().hide();
hideActionBar();
viewHolder = new ViewHolder (this);
setContentView (viewHolder);
@ -176,6 +176,49 @@ public class JuceAppActivity extends Activity
getApplicationInfo().dataDir);
}
private void hideActionBar()
{
// get "getActionBar" method
java.lang.reflect.Method getActionBarMethod = null;
try
{
getActionBarMethod = this.getClass().getMethod ("getActionBar");
}
catch (SecurityException e) { return; }
catch (NoSuchMethodException e) { return; }
if (getActionBarMethod == null) return;
// invoke "getActionBar" method
Object actionBar = null;
try
{
actionBar = getActionBarMethod.invoke (this);
}
catch (java.lang.IllegalArgumentException e) { return; }
catch (java.lang.IllegalAccessException e) { return; }
catch (java.lang.reflect.InvocationTargetException e) { return; }
if (actionBar == null) return;
// get "hide" method
java.lang.reflect.Method actionBarHideMethod = null;
try
{
actionBarHideMethod = actionBar.getClass().getMethod ("hide");
}
catch (SecurityException e) { return; }
catch (NoSuchMethodException e) { return; }
if (actionBarHideMethod == null) return;
// invoke "hide" method
try
{
actionBarHideMethod.invoke (actionBar);
}
catch (java.lang.IllegalArgumentException e) {}
catch (java.lang.IllegalAccessException e) {}
catch (java.lang.reflect.InvocationTargetException e) {}
}
//==============================================================================
private native void launchApp (String appFile, String appDataDir);
private native void quitApp();
@ -924,7 +967,7 @@ public class JuceAppActivity extends Activity
return Environment.getExternalStoragePublicDirectory (type).getAbsolutePath();
}
public static final String getDocumentsFolder() { return getFileLocation (Environment.DIRECTORY_DOCUMENTS); }
public static final String getDocumentsFolder() { return Environment.getDataDirectory().getAbsolutePath(); }
public static final String getPicturesFolder() { return getFileLocation (Environment.DIRECTORY_PICTURES); }
public static final String getMusicFolder() { return getFileLocation (Environment.DIRECTORY_MUSIC); }
public static final String getMoviesFolder() { return getFileLocation (Environment.DIRECTORY_MOVIES); }