Android Open Source - HexNanoController_Android Hex Mini Application






From Project

Back to project page HexNanoController_Android.

License

The source code is released under:

Code license GNU GPL v2 http://www.gnu.org/licenses/gpl.html Content license CC BY-NC-SA 4.0 http://creativecommons.org/licenses/by-nc-sa/4.0/

If you think the Android project HexNanoController_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hexairbot.hexmini;
/* w  ww. ja  va  2s .  co m*/
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.annotation.SuppressLint;
import android.app.Application;
import android.content.res.AssetManager;
import android.util.Log;

import com.hexairbot.hexmini.modal.ApplicationSettings;
import com.hexairbot.hexmini.util.FileHelper;

public class HexMiniApplication extends Application 
{   
  private static final String TAG = HexMiniApplication.class.getSimpleName();
    
  private static HexMiniApplication instance;
  
  private ApplicationSettings settings;
  private FileHelper fileHelper;
  
  private AppStage appStage = AppStage.UNKNOWN;
  
  
  public enum AppStage{
    UNKNOWN,
    HUD,
    SETTINGS
  };
    
  
  @SuppressLint("NewApi")
    @Override
  public void onCreate() 
  {
    super.onCreate();
    Log.d(TAG, "OnCreate");
    
    instance = this;

    fileHelper = new FileHelper(this);
    
    copyDefaultSettingsFileIfNeeded();
    
    settings = new ApplicationSettings(getFilesDir() + "/Settings.plist");
  }
  
  
  @Override
  public void onTerminate() 
  {
    Log.d(TAG, "OnTerminate");
    super.onTerminate();
  }

  
  public ApplicationSettings getAppSettings()
  {
    return settings;
  }
  
  public FileHelper getFileHelper(){
    return fileHelper;
  }
  
  
    public static HexMiniApplication sharedApplicaion() {  
        return instance;  
    }  
    
    
    private void copyDefaultSettingsFileIfNeeded(){
    String settingsFileName        = "Settings.plist";        //user
    String defaultSettingsFileName = "DefaultSettings.plist"; //default

    if (fileHelper.hasDataFile(settingsFileName) == false) {
      AssetManager assetManager = getAssets();
      
      InputStream in = null;
      OutputStream out = null;
      try {
        in = assetManager.open(settingsFileName);
        out =  openFileOutput(settingsFileName, MODE_PRIVATE);

        byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) != -1) {
          out.write(buffer, 0, read);
        }

        in.close();
        in = null;
        out.flush();
        out.close();
        out = null;
      } catch (IOException e) {
        Log.e("tag", "Failed to copy asset file: " + settingsFileName, e);
      }
    }
    
    if (fileHelper.hasDataFile(defaultSettingsFileName) == false) {
      AssetManager assetManager = getAssets();
      
      InputStream in = null;
      OutputStream out = null;
      try {
        in = assetManager.open(settingsFileName);
        out =  openFileOutput(defaultSettingsFileName, MODE_PRIVATE);

        byte[] buffer = new byte[1024];
        int read;
        while ((read = in.read(buffer)) != -1) {
          out.write(buffer, 0, read);
        }

        in.close();
        in = null;
        out.flush();
        out.close();
        out = null;
      } catch (IOException e) {
        Log.e("tag", "Failed to copy asset file: " + settingsFileName, e);
      }
    }
    }


  public AppStage getAppStage() {
    return appStage;
  }


  public void setAppStage(AppStage appStage) {
    this.appStage = appStage;
  }
}




Java Source Code List

.FileHelper.java
.Input.java
.Output.java
.Serializable.java
com.hexairbot.hexmini.HelpActivity.java
com.hexairbot.hexmini.HexMiniApplication.java
com.hexairbot.hexmini.HudActivity.java
com.hexairbot.hexmini.HudViewControllerDelegate.java
com.hexairbot.hexmini.HudViewController.java
com.hexairbot.hexmini.SettingsDialogDelegate.java
com.hexairbot.hexmini.SettingsDialog.java
com.hexairbot.hexmini.SettingsViewControllerDelegate.java
com.hexairbot.hexmini.SettingsViewController.java
com.hexairbot.hexmini.ViewController.java
com.hexairbot.hexmini.adapter.SettingsViewAdapter.java
com.hexairbot.hexmini.ble.BleConnectinManagerDelegate.java
com.hexairbot.hexmini.ble.BleConnectinManager.java
com.hexairbot.hexmini.ble.BluetoothLeService.java
com.hexairbot.hexmini.gestures.EnhancedGestureDetector.java
com.hexairbot.hexmini.modal.ApplicationSettings.java
com.hexairbot.hexmini.modal.Channel.java
com.hexairbot.hexmini.modal.OSDCommon.java
com.hexairbot.hexmini.modal.Transmitter.java
com.hexairbot.hexmini.sensors.DeviceOrientationChangeDelegate.java
com.hexairbot.hexmini.sensors.DeviceOrientationManager.java
com.hexairbot.hexmini.sensors.DeviceSensorManagerWrapper.java
com.hexairbot.hexmini.sensors.SensorManagerWrapper.java
com.hexairbot.hexmini.services.ConnectStateManager.java
com.hexairbot.hexmini.services.IpcControlService.java
com.hexairbot.hexmini.services.IpcProxy.java
com.hexairbot.hexmini.services.NavData.java
com.hexairbot.hexmini.services.OnIpcConnectChangedListener.java
com.hexairbot.hexmini.services.VIConfig.java
com.hexairbot.hexmini.ui.Button.java
com.hexairbot.hexmini.ui.Image.java
com.hexairbot.hexmini.ui.Indicator.java
com.hexairbot.hexmini.ui.Sprite.java
com.hexairbot.hexmini.ui.Text.java
com.hexairbot.hexmini.ui.ToggleButton.java
com.hexairbot.hexmini.ui.UIRenderer.java
com.hexairbot.hexmini.ui.control.CustomSeekBar.java
com.hexairbot.hexmini.ui.control.ViewPagerIndicator.java
com.hexairbot.hexmini.ui.gl.GLSprite.java
com.hexairbot.hexmini.ui.joystick.AcceleratorJoystick.java
com.hexairbot.hexmini.ui.joystick.AnalogueJoystick.java
com.hexairbot.hexmini.ui.joystick.JoystickBase.java
com.hexairbot.hexmini.ui.joystick.JoystickFactory.java
com.hexairbot.hexmini.ui.joystick.JoystickListener.java
com.hexairbot.hexmini.util.DebugHandler.java
com.hexairbot.hexmini.util.FontUtils.java
com.hexairbot.hexmini.util.SystemUiHiderBase.java
com.hexairbot.hexmini.util.SystemUiHiderHoneycomb.java
com.hexairbot.hexmini.util.SystemUiHider.java
com.hexairbot.hexmini.util.SystemUtil.java
com.hexairbot.hexmini.util.TextureUtils.java
fix.android.opengl.GLES20.java