Android Open Source - CallerFlashlight First Time Utilisation






From Project

Back to project page CallerFlashlight.

License

The source code is released under:

GNU General Public License

If you think the Android project CallerFlashlight 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.spirosbond.callerflashlight;
/*  w w w  . ja  va  2s  .co  m*/
import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Spinner;

/**
 * Created by spiros on 10/12/13.
 */
public class FirstTimeUtilisation extends Activity implements View.OnClickListener, AdapterView.OnItemSelectedListener {

  private static final String TAG = FirstTimeUtilisation.class.getSimpleName();
  private CallerFlashlight callerFlashlight;
  private Button contButton;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (CallerFlashlight.LOG) Log.d(TAG, "onCreated");
    setContentView(R.layout.first_time);
    callerFlashlight = (CallerFlashlight) getApplication();
    Button testButton = (Button) findViewById(R.id.firstFlashTest);
    testButton.setOnClickListener(this);
    contButton = (Button) findViewById(R.id.firstcontinue);
    contButton.setOnClickListener(this);
    Spinner moduleList = (Spinner) findViewById(R.id.module_list);
    moduleList.setOnItemSelectedListener(this);
    ImageView logo = (ImageView) findViewById(R.id.logo);
    logo.startAnimation(AnimationUtils.loadAnimation(this, R.anim.round));

  }

  @Override
  protected void onResume() {
    super.onResume();
    if (CallerFlashlight.LOG) Log.d(TAG, "onResumed");
  }

  @Override
  public void onBackPressed() {
    //    super.onBackPressed();
    return;

  }

  @Override
  public void onClick(View view) {
    switch (view.getId()) {
      case R.id.firstFlashTest:
        //          callerFlashlight.setMsgFlashTest(false);
        new ManageFlash().execute();
        //          startActivity(new Intent(this, CameraSurface.class));
        contButton.setEnabled(true);
        break;
      case R.id.firstcontinue:
        setResult(RESULT_OK, new Intent());
        finish();
        break;
    }

  }

  @Override
  public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
    if (CallerFlashlight.LOG) Log.d(TAG, "onItemClick " + i + 1);
    callerFlashlight.setType(i + 1);
    callerFlashlight.setWindowDimensions(getWindowManager());
  }

  @Override
  public void onNothingSelected(AdapterView<?> adapterView) {

  }

  public class ManageFlash extends AsyncTask<Integer, Integer, String> {


    private int flashes = 3;
    private Flash flash;

    public ManageFlash() {

      flash = new Flash(callerFlashlight);
      Flash.incRunning();
    }

    @Override
    protected String doInBackground(Integer... integers) {
      if (CallerFlashlight.LOG) Log.d(TAG, "doInBackgroung Started");

      while (flashes > 0) {
        flash.enableFlash(callerFlashlight.getCallFlashOnDuration(), callerFlashlight.getCallFlashOffDuration());
        flashes -= 1;
      }


      return null;
    }

    @Override
    protected void onPostExecute(String s) {
      super.onPostExecute(s);
      if (CallerFlashlight.LOG) Log.d(TAG, "onPostExecute Started");
      Flash.decRunning();
      if (Flash.getRunning() == 0) Flash.releaseCam();
    }

    @Override
    protected void onCancelled() {
      super.onCancelled();
      if (CallerFlashlight.LOG) Log.d(TAG, "onCancelled Started");
      Flash.decRunning();
      if (Flash.getRunning() == 0) Flash.releaseCam();
    }

  }


}




Java Source Code List

com.spirosbond.callerflashlight.About.java
com.spirosbond.callerflashlight.AdPreference2.java
com.spirosbond.callerflashlight.AdPreference.java
com.spirosbond.callerflashlight.AppList.java
com.spirosbond.callerflashlight.BatteryLevelReceiver.java
com.spirosbond.callerflashlight.BootReceiver.java
com.spirosbond.callerflashlight.CallPrefs.java
com.spirosbond.callerflashlight.CallReceiver.java
com.spirosbond.callerflashlight.CallerFlashlight.java
com.spirosbond.callerflashlight.CameraSurface.java
com.spirosbond.callerflashlight.Donate.java
com.spirosbond.callerflashlight.FirstTimeUtilisation.java
com.spirosbond.callerflashlight.Flash.java
com.spirosbond.callerflashlight.InteractiveArrayAdapter.java
com.spirosbond.callerflashlight.License.java
com.spirosbond.callerflashlight.MainPanel.java
com.spirosbond.callerflashlight.MediaButtonReceiver.java
com.spirosbond.callerflashlight.Model.java
com.spirosbond.callerflashlight.MsgPrefs.java
com.spirosbond.callerflashlight.NotificationService.java
com.spirosbond.callerflashlight.PrefsActivity.java
com.spirosbond.callerflashlight.SeekBarPreference.java
com.spirosbond.callerflashlight.SmsReceiver.java
com.spirosbond.callerflashlight.SortByCheck.java
com.spirosbond.callerflashlight.SortByString.java
com.spirosbond.callerflashlight.TimePreference.java