// 设置屏幕亮度[0---255]
 public void setBrightnessValue(Activity activity, int brightnessValue) {
   if (brightnessValue < 0) brightnessValue = 0;
   if (brightnessValue > 255) brightnessValue = 255;
   WindowManager.LayoutParams layoutParams = activity.getWindow().getAttributes();
   layoutParams.screenBrightness = Float.valueOf(brightnessValue * (1f / 255f));
   activity.getWindow().setAttributes(layoutParams);
 }
Exemplo n.º 2
1
  public static void setCurWindowBrightness(Context context, int brightness) {

    // 如果开启自动亮度,则关闭。否则,设置了亮度值也是无效的
    if (IsAutoBrightness(context)) {
      stopAutoBrightness(context);
    }

    // context转换为Activity
    Activity activity = (Activity) context;
    WindowManager.LayoutParams lp = activity.getWindow().getAttributes();

    // 异常处理
    if (brightness < 1) {
      brightness = 1;
    }

    // 异常处理
    if (brightness > 255) {
      brightness = 255;
    }

    lp.screenBrightness = Float.valueOf(brightness) * (1f / 255f);

    activity.getWindow().setAttributes(lp);
  }
 private void applyBrightness(State state) {
   if (state.forceDozeBrightness) {
     mLpChanged.screenBrightness = mScreenBrightnessDoze;
   } else {
     mLpChanged.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
   }
 }
 /// BRIGHTNESS MODE
 private void refreshBrightness(float brightness) {
   WindowManager.LayoutParams lp = getWindow().getAttributes();
   if (brightness < 0) {
     lp.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
   } else {
     lp.screenBrightness = brightness;
   }
   getWindow().setAttributes(lp);
 }
Exemplo n.º 5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_blackout);

    // Hide the status bar.
    View decorView = getWindow().getDecorView();
    int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
    decorView.setSystemUiVisibility(uiOptions);

    // Sets screen brightness to lowest possible setting
    WindowManager.LayoutParams params = getWindow().getAttributes();
    params.screenBrightness = 0;
    getWindow().setAttributes(params);

    // Ensures the device won't lock while the app is running
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // begins listening for audio
    // this will detect the sound from the user
    try {
      bufferSize =
          AudioRecord.getMinBufferSize(
              sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT);
    } catch (Exception e) {
      android.util.Log.e("TrackingFlow", "Exception", e);
    }
  }
Exemplo n.º 6
0
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Window window = getWindow();
   // Flashlights should be bright.
   WindowManager.LayoutParams params = window.getAttributes();
   params.screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_FULL;
   // params.buttonBrightness was added in API level 8. The additional brightness is not worth the
   // added code size.
   // The screen will go to max brightness even without the following line, but the API doesn't
   // guarantee it.
   window.setAttributes(params);
   window.addFlags(
       // Use the power button to turn flashlight off and on, even if you have a lock screen.
       WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
           // We won't do anything with touch events. Don't bother sending them to us.
           // Unfortunately, there is a platform bug that still exists in 4.2 (!) that causes ANRs
           // if this
           // flag is set.
           // | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
           // A flashlight that turns itself off isn't a good flashlight.
           | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
           // Turn the screen on if it isn't already on when launching (e.g., from ADB).
           | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
 }
Exemplo n.º 7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    // No Titlebar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    /*		getWindow().getDecorView().setSystemUiVisibility(
    View.SYSTEM_UI_FLAG_LAYOUT_STABLE
    		| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
    		| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
    		| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
    		| View.SYSTEM_UI_FLAG_FULLSCREEN
    		| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);*/
    View main = LayoutInflater.from(this).inflate(R.layout.temp_alert, null);
    main.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    super.onCreate(savedInstanceState);
    setContentView(main);
    // enterLightsOutMode(getWindow());
    MainApplication.tempActivity = this;

    WindowManager.LayoutParams localLayoutParams = getWindow().getAttributes();
    localLayoutParams.screenBrightness = 15 / 255.0F;
    getWindow().setAttributes(localLayoutParams);

    final IntentFilter homeFilter = new IntentFilter(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
    mScreenOffReceiver = new BNRBroadCast();
    registerReceiver(mScreenOffReceiver, homeFilter);
    Intent intnet = new Intent("android.intent.action.CLOSE_WAKEUP");
    sendBroadcast(intnet);
  }
Exemplo n.º 8
0
 // 设置屏幕亮度
 public void screenBrightness(float value) {
   try {
     WindowManager.LayoutParams layout = getWindow().getAttributes();
     layout.screenBrightness = value; // 0最弱 1最亮
     getWindow().setAttributes(layout);
   } catch (Exception e) {
   }
 }
Exemplo n.º 9
0
  /** setBrightness */
  public static void setBrightness(Activity activity, int brightness) {
    // Settings.System.putInt(activity.getContentResolver(),
    // Settings.System.SCREEN_BRIGHTNESS_MODE,
    // Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);

    WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
    lp.screenBrightness = Float.valueOf(brightness) * (1f / 255f);
    activity.getWindow().setAttributes(lp);
  }
Exemplo n.º 10
0
  @Override
  protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    setContentView(new PointerLocationView(this));

    // Make the screen full bright for this activity.
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 1.0f;
    getWindow().setAttributes(lp);
  }
 /** 根据日间/夜间模式调整应用程序的亮度 */
 public static void setScreenBrightness(Activity act) {
   Window localWindow = act.getWindow();
   WindowManager.LayoutParams localLayoutParams = localWindow.getAttributes();
   float f = 0.08F;
   if (App.getDispalyModel() == Constants.DISPLAY_MODEL_DAY) {
     f = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE;
   }
   localLayoutParams.screenBrightness = f;
   localWindow.setAttributes(localLayoutParams);
 }
Exemplo n.º 12
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Set screen brightness
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 100 / 100.0f;
    getWindow().setAttributes(lp);
  }
Exemplo n.º 13
0
  private void onBrightnessSlide(float percent) {
    if (mBrightness < 0) {
      mBrightness = getWindow().getAttributes().screenBrightness;
      if (mBrightness <= 0.00f) mBrightness = 0.50f;
      if (mBrightness < 0.01f) mBrightness = 0.01f;

      //
      mOperationBg.setImageResource(R.drawable.video_brightness_bg);
      mVolumeBrightnessLayout.setVisibility(View.VISIBLE);
    }
    WindowManager.LayoutParams lpa = getWindow().getAttributes();
    lpa.screenBrightness = mBrightness + percent;
    if (lpa.screenBrightness > 1.0f) lpa.screenBrightness = 1.0f;
    else if (lpa.screenBrightness < 0.01f) lpa.screenBrightness = 0.01f;
    getWindow().setAttributes(lpa);

    ViewGroup.LayoutParams lp = mOperationPercent.getLayoutParams();
    lp.width =
        (int) (findViewById(R.id.operation_full).getLayoutParams().width * lpa.screenBrightness);
    mOperationPercent.setLayoutParams(lp);
  }
Exemplo n.º 14
0
 private void initializeScreenBrightness() {
   Window win = getWindow();
   // Overright the brightness settings if it is automatic
   int mode =
       Settings.System.getInt(
           getContentResolver(),
           Settings.System.SCREEN_BRIGHTNESS_MODE,
           Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
   if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
     WindowManager.LayoutParams winParams = win.getAttributes();
     winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
     win.setAttributes(winParams);
   }
 }
 /**
  * 设置给定Activity的窗口的亮度(可以看到效果,但系统的亮度属性不会改变)
  *
  * @param activity 要通过此Activity来设置窗口的亮度
  * @param screenBrightness 亮度,范围是0-255
  */
 public static void setWindowBrightness(Activity activity, float screenBrightness) {
   float brightness = screenBrightness;
   if (screenBrightness < 1) {
     brightness = 1;
   } else if (screenBrightness > 255) {
     brightness = screenBrightness % 255;
     if (brightness == 0) {
       brightness = 255;
     }
   }
   Window window = activity.getWindow();
   WindowManager.LayoutParams localLayoutParams = window.getAttributes();
   localLayoutParams.screenBrightness = brightness / 255;
   window.setAttributes(localLayoutParams);
 }
Exemplo n.º 16
0
  public void setVisible() {

    /** Start test Settings screen brightness is the largest */
    WindowManager.LayoutParams lp = ItemTestActivity.itemActivity.getWindow().getAttributes();
    lp.screenBrightness = Float.valueOf(255) * (1f / 255f);
    ItemTestActivity.itemActivity.getWindow().setAttributes(lp);

    /** Hide button */
    ItemTestActivity.itemActivity.handler.sendEmptyMessage(ItemTestActivity.MSG_BTNBAR_INVISIBLE);
    /** Set no title, full screen */
    ItemTestActivity.itemActivity.requestWindowFeature(Window.FEATURE_NO_TITLE);
    ItemTestActivity.itemActivity.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    ItemTestActivity.itemActivity
        .getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }
 private void setClockStyle() {
   Utils.setClockStyle(
       this, mDigitalClock, mAnalogClock, ScreensaverSettingsActivity.KEY_CLOCK_STYLE);
   mSaverView = findViewById(R.id.main_clock);
   int brightness =
       PreferenceManager.getDefaultSharedPreferences(this)
           .getInt(
               ScreensaverSettingsActivity.KEY_BRIGHTNESS,
               ScreensaverSettingsActivity.BRIGHTNESS_DEFAULT);
   Utils.dimView(brightness, mSaverView);
   boolean dim = brightness < ScreensaverSettingsActivity.BRIGHTNESS_NIGHT;
   if (dim) {
     WindowManager.LayoutParams lp = getWindow().getAttributes();
     lp.buttonBrightness = 0;
     lp.screenBrightness = 0.01f;
     getWindow().setAttributes(lp);
   }
 }
Exemplo n.º 18
0
  @UiThread
  void changeBrightness(float percent) {
    WindowManager.LayoutParams lpa = getWindow().getAttributes();
    float brightness = lpa.screenBrightness;
    if (brightness <= 0.00f) brightness = 0.50f;
    if (brightness < 0.01f) brightness = 0.01f;

    brightness = brightness + percent;
    if (brightness < 0.01f) {
      brightness = 0.01f;
    } else if (brightness > 1.0f) {
      brightness = 1.0f;
    }
    lpa.screenBrightness = brightness;
    getWindow().setAttributes(lpa);

    // 更新ui
    ViewGroup.LayoutParams lp = sideBright.getLayoutParams();
    lp.height =
        (int)
            (sideBrightRoot.findViewById(R.id.value_img_bg).getLayoutParams().height * brightness);
    sideBright.setLayoutParams(lp);
  }
Exemplo n.º 19
0
 public static void setWindowBrightness(Window window, float screenBrightness) {
   WindowManager.LayoutParams layoutParams = window.getAttributes();
   layoutParams.screenBrightness = screenBrightness;
   window.setAttributes(layoutParams);
 }
Exemplo n.º 20
0
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // window properties, called before layout is loaded
    getWindow()
        .setFlags(
            WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.splash);

    // brightness
    // Make the screen full bright for this activity.
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 0.5f;

    // Play Intro Sound
    // mp_intro.reset();
    // String my_path1="/sdcard/notours/system_sounds/welcome_to_notours.mp3";

    // Setting latitude and longitude in the TextView tv_location

    // noTours version
    /*
    TextView tvLocation = (TextView) findViewById(R.id.noTours_version);
        	tvLocation.setText("v2.0.3.Http");
        	tvLocation.setTypeface(null, Typeface.ITALIC);
        	tvLocation.bringToFront();
        	//tvLocation.setHeight(40);
        	tvLocation.setTextColor(Color.LTGRAY);
        	tvLocation.setTextSize(10);
     */

    mp_intro = MediaPlayer.create(this, R.raw.welcome);
    // mp_intro.setDataSource(my_path1);

    // mp_intro.setVolume(1.0f, 1.0f);

    // if(mp_intro.isPlaying()==false) {
    // Log.v("home sound","entrooo");
    mp_intro.start();
    // Log.v("home sound","start");
    // i.e. react on the end of the music-file:
    mp_intro.setOnCompletionListener(
        new OnCompletionListener() {

          // @Override
          public void onCompletion(MediaPlayer arg0) {
            // File has ended !!! Wink
            // Log.v("Intro Sounde"," he terminaaaaaaaaaaaaaaado");
            if (mp_intro.isPlaying()) {
              mp_intro.stop();
            }
            mp_intro.reset();
            mp_intro.release();
          }
        });
    // }
    // End of Play Intro Sound

    // check if noTours directory exists, if not create it!
    File testDirectory = new File(Environment.getExternalStorageDirectory() + "/notours");
    if (!testDirectory.exists()) {
      File nfile = new File(Environment.getExternalStorageDirectory() + "/notours");
      nfile.mkdir();
    }
    File testDirectory22 = new File("/storage/emulated/0/notours/");
    if (!testDirectory22.exists()) {
      File nfile2 = new File("/storage/emulated/0/notours/");
      nfile2.mkdir();
    }

    // copy files from assests if necessary for having a demo!!
    File testDirectory2 =
        new File(Environment.getExternalStorageDirectory() + "/notours/noToursDemo");
    if (!testDirectory2.exists()) {
      File nfile2 = new File(Environment.getExternalStorageDirectory() + "/notours/noToursDemo");
      nfile2.mkdir();
      File nfile3 =
          new File(Environment.getExternalStorageDirectory() + "/notours/noToursDemo/sound");
      nfile3.mkdir();
      copyDemoProject();
    }
    File testDirectory23 = new File("/storage/emulated/0/notours/noToursDemo");
    if (!testDirectory23.exists()) {
      File nfile2 = new File("/storage/emulated/0/notours/noToursDemo");
      nfile2.mkdir();
      File nfile3 = new File("/storage/emulated/0/notours/noToursDemo/sound");
      nfile3.mkdir();
      copyDemoProject2();
    }

    // Re-scan directory for making it available to the users
    // File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM);
    File path11 = new File("/storage/emulated/0/notours/");
    path11.mkdirs();

    // fix
    path11.setExecutable(true);
    path11.setReadable(true);
    path11.setWritable(true);

    // initiate media scan and put the new things into the path array to
    // make the scanner aware of the location and the files you want to see
    MediaScannerConnection.scanFile(this, new String[] {path11.toString()}, null, null);

    // For a specific the project
    // check if noTours directory exists, if not create it!
    /*
    File testDirectory3 = new File(Environment.getExternalStorageDirectory() + "/notours/carcassonne");
    if(!testDirectory3.exists()){
    	File nfile4=new File(Environment.getExternalStorageDirectory()+"/notours/carcassonne");
    	nfile4.mkdir();
    	File nfile5=new File(Environment.getExternalStorageDirectory()+"/notours/carcassonne/sound");
    	nfile5.mkdir();
    	File nfile6=new File(Environment.getExternalStorageDirectory()+"/notours/carcassonne/track");
    	nfile6.mkdir();
    	File nfile7=new File(Environment.getExternalStorageDirectory()+"/notours/carcassonne/image");
    	nfile7.mkdir();
    }
    */

    // thread for displaying the SplashScreen
    Thread splashTread =
        new Thread() {
          @Override
          public void run() {
            try {
              int waited = 0;
              while (_active && (waited < _splashTime)) {
                sleep(100);
                if (_active) {
                  waited += 100;
                }
              }
            } catch (InterruptedException e) {
              // do nothing
            } finally {
              finish();
              // go to the menu
              startActivity(
                  new Intent(
                      "com.example.mapdemo.escoitar.Projects")); // "com.noTours.escoitar.noTours.Menu"));
              // go to the projects menu
              // startActivity(new Intent("com.noTours.escoitar.noTours.Projects"));
              // MenuContinent.c

              // stop();
            }
          }
        };
    splashTread.start();
  }
Exemplo n.º 21
0
 private void setBrightness(int paramInt) {
   WindowManager.LayoutParams lp = getWindow().getAttributes();
   float brightness = (float) paramInt / MAXIMUM_BRIGHTNESS;
   lp.screenBrightness = brightness;
   getWindow().setAttributes(lp);
 }
Exemplo n.º 22
0
  @SuppressWarnings("deprecation")
  public void onClick(View v) {
    final Context context = this;

    switch (v.getId()) {
      case R.id.Answering:
        Intent intentAsking = new Intent(context, AdultHomePage.class);
        startActivity(intentAsking);
        break;

      case R.id.notification:
        Intent intent = new Intent(context, AdultNotification.class);
        startActivity(intent);
        break;

      case R.id.AnswerBank:
        Intent intentQnBank = new Intent(context, AnswerBankAccepted.class);
        startActivity(intentQnBank);
        break;

      case R.id.Setting:
        Intent intentSetting = new Intent(context, AdultSetting.class);
        startActivity(intentSetting);
        break;

      case R.id.Q1:
        setContentView(R.layout.activity_faqinstance_adult);

        loginUser = BrainJuice.retrieveLoginUser();
        userMgr = BrainJuice.retrieveUserMgr();

        icon = (ImageView) this.findViewById(R.id.qnprofilepic);
        int j =
            getResources()
                .getIdentifier(
                    userMgr.retrieveUser(loginUser).getProfile(), "drawable", getPackageName());
        icon.setImageResource(j);

        welcomeMsg = (TextView) this.findViewById(R.id.widget50);
        welcomeMsg.setText(Html.fromHtml("Hi, " + loginUser));
        checkNotification();
        TextView title = (TextView) this.findViewById(R.id.FAQTitle);
        title.setText(Html.fromHtml("How do I answer a question?<br />"));

        TextView body = (TextView) this.findViewById(R.id.FAQBody);
        body.setText(
            Html.fromHtml(
                "<b>Step 1</b> When you want to answer a question, simply tap on the “Question Request” navigation tab.<br /><br />"
                    + "<b>Step 2</b> For the first time, you will see a red button called “Give Me a Question Now!”<br /><br />"
                    + "<b>Step 3</b> At the “Question Request” page, you will be presented with a question asked by a primary school student. You can choose to answer it by keying your answer into the textbox area. Alternatively, if you prefer to answer other question instead, simply tap the “Another Question” button, and a new question will be posted to you.<br /><br />"
                    + "<b>Step 4</b> Tap the “Answer” button, and your answer will be sent to primary school student who initiated the question."));

        ImageButton faq = (ImageButton) this.findViewById(R.id.FAQ);
        faq.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultFaq.class);
                startActivity(intent);
              }
            });

        ImageButton asking = (ImageButton) this.findViewById(R.id.Answering);
        asking.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultHomePage.class);
                startActivity(intent);
              }
            });
        ImageButton notification = (ImageButton) this.findViewById(R.id.notification);
        notification.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultNotification.class);
                startActivity(intent);
              }
            });

        ImageButton qnBank = (ImageButton) this.findViewById(R.id.AnswerBank);
        qnBank.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AnswerBankAccepted.class);
                startActivity(intent);
              }
            });

        ImageButton setting = (ImageButton) this.findViewById(R.id.Setting);
        setting.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultSetting.class);
                startActivity(intent);
              }
            });

        final ImageButton logoutQ1 = (ImageButton) this.findViewById(R.id.Logout);
        logoutQ1.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                LayoutInflater layoutInflaterLogout =
                    (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
                View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
                final PopupWindow popupWindowLogout =
                    new PopupWindow(
                        popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                popupWindowLogout.setOutsideTouchable(false);
                popupWindowLogout.setFocusable(true);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue / 500.0f;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  e.printStackTrace();
                }

                Button btnDismissLogout = (Button) popupViewLogout.findViewById(R.id.Cancel);
                btnDismissLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        popupWindowLogout.dismiss();

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });

                Button btnProceedLogout = (Button) popupViewLogout.findViewById(R.id.Proceed);
                btnProceedLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        BrainJuice.removeLoginUser();
                        Intent intent = new Intent(context, BrainJuice.class);
                        startActivity(intent);

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });
                popupWindowLogout.showAsDropDown(logoutQ1, 150, 50);
              }
            });

        break;

      case R.id.Q2:
        setContentView(R.layout.activity_faqinstance_adult);

        loginUser = BrainJuice.retrieveLoginUser();
        userMgr = BrainJuice.retrieveUserMgr();

        icon = (ImageView) this.findViewById(R.id.qnprofilepic);
        int jQ2 =
            getResources()
                .getIdentifier(
                    userMgr.retrieveUser(loginUser).getProfile(), "drawable", getPackageName());
        icon.setImageResource(jQ2);

        welcomeMsg = (TextView) this.findViewById(R.id.widget50);
        welcomeMsg.setText(Html.fromHtml("Hi, " + loginUser));
        checkNotification();
        TextView titleQ2 = (TextView) this.findViewById(R.id.FAQTitle);
        titleQ2.setText(Html.fromHtml("How do I know if my answer has been accepted?<br />"));

        TextView bodyQ2 = (TextView) this.findViewById(R.id.FAQBody);
        bodyQ2.setText(
            Html.fromHtml(
                "<b>Step 1</b> When you have a notification, it means that some primary school student user has acknowledged your answer.<br /><br />"
                    + "<b>Step 2</b> To check your notification, tap on the “Notifications” navigation tab.<br /><br />"
                    + "<b>Step 3</b> All notifications will be populated. Select the notification you would like to view.<br /><br />"
                    + "<b>Step 4</b> You will see the question asked, and the answer provided by yourself. Additionally, you will be able to see if your answer has been accepted or rejected by the primary school student. When accepted, the notification will show that the primary school student likes your answer (and vice versa). The question asked and answer provided will be stored in your “Answer Bank”.<br /><br />"));

        ImageButton faqQ2 = (ImageButton) this.findViewById(R.id.FAQ);
        faqQ2.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultFaq.class);
                startActivity(intent);
              }
            });

        ImageButton askingQ2 = (ImageButton) this.findViewById(R.id.Answering);
        askingQ2.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultHomePage.class);
                startActivity(intent);
              }
            });
        ImageButton notificationQ2 = (ImageButton) this.findViewById(R.id.notification);
        notificationQ2.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultNotification.class);
                startActivity(intent);
              }
            });

        ImageButton qnBankQ2 = (ImageButton) this.findViewById(R.id.AnswerBank);
        qnBankQ2.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AnswerBankAccepted.class);
                startActivity(intent);
              }
            });

        ImageButton settingQ2 = (ImageButton) this.findViewById(R.id.Setting);
        settingQ2.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultSetting.class);
                startActivity(intent);
              }
            });

        final ImageButton logoutQ2 = (ImageButton) this.findViewById(R.id.Logout);
        logoutQ2.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                LayoutInflater layoutInflaterLogout =
                    (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
                View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
                final PopupWindow popupWindowLogout =
                    new PopupWindow(
                        popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                popupWindowLogout.setOutsideTouchable(false);
                popupWindowLogout.setFocusable(true);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue / 500.0f;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  e.printStackTrace();
                }

                Button btnDismissLogout = (Button) popupViewLogout.findViewById(R.id.Cancel);
                btnDismissLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        popupWindowLogout.dismiss();

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });

                Button btnProceedLogout = (Button) popupViewLogout.findViewById(R.id.Proceed);
                btnProceedLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        BrainJuice.removeLoginUser();
                        Intent intent = new Intent(context, BrainJuice.class);
                        startActivity(intent);

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });
                popupWindowLogout.showAsDropDown(logoutQ2, 150, 50);
              }
            });

        break;

      case R.id.Q3:
        setContentView(R.layout.activity_faqinstance_adult);

        loginUser = BrainJuice.retrieveLoginUser();
        userMgr = BrainJuice.retrieveUserMgr();

        icon = (ImageView) this.findViewById(R.id.qnprofilepic);
        int jQ3 =
            getResources()
                .getIdentifier(
                    userMgr.retrieveUser(loginUser).getProfile(), "drawable", getPackageName());
        icon.setImageResource(jQ3);

        welcomeMsg = (TextView) this.findViewById(R.id.widget50);
        welcomeMsg.setText(Html.fromHtml("Hi, " + loginUser));
        checkNotification();
        TextView titleQ3 = (TextView) this.findViewById(R.id.FAQTitle);
        titleQ3.setText(
            Html.fromHtml("Where are my answers to the questions asked located?<br />"));

        TextView bodyQ3 = (TextView) this.findViewById(R.id.FAQBody);
        bodyQ3.setText(
            Html.fromHtml(
                "<b>Step 1</b> Tap on the “Answer Bank” navigation tab.<br /><br />"
                    + "<b>Step 2</b> Select the “Accepted” tab to look at your answers that were accepted by the primary school students who asked the questions. Select the “Rejected” tab to look at your answers that were rejected by the primary school students who asked the questions. Select the “Pending Acceptance” tab to look at your answers that were yet to be acknowledged by the primary school students who asked the questions. There is a “search” textbox where you can search for a question with keywords entered.<br /><br />"));

        ImageButton faqQ3 = (ImageButton) this.findViewById(R.id.FAQ);
        faqQ3.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultFaq.class);
                startActivity(intent);
              }
            });

        ImageButton askingQ3 = (ImageButton) this.findViewById(R.id.Answering);
        askingQ3.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultHomePage.class);
                startActivity(intent);
              }
            });
        ImageButton notificationQ3 = (ImageButton) this.findViewById(R.id.notification);
        notificationQ3.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultNotification.class);
                startActivity(intent);
              }
            });

        ImageButton qnBankQ3 = (ImageButton) this.findViewById(R.id.AnswerBank);
        qnBankQ3.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AnswerBankAccepted.class);
                startActivity(intent);
              }
            });

        ImageButton settingQ3 = (ImageButton) this.findViewById(R.id.Setting);
        settingQ3.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultSetting.class);
                startActivity(intent);
              }
            });

        final ImageButton logoutQ3 = (ImageButton) this.findViewById(R.id.Logout);
        logoutQ3.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                LayoutInflater layoutInflaterLogout =
                    (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
                View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
                final PopupWindow popupWindowLogout =
                    new PopupWindow(
                        popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                popupWindowLogout.setOutsideTouchable(false);
                popupWindowLogout.setFocusable(true);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue / 500.0f;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  e.printStackTrace();
                }

                Button btnDismissLogout = (Button) popupViewLogout.findViewById(R.id.Cancel);
                btnDismissLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        popupWindowLogout.dismiss();

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });

                Button btnProceedLogout = (Button) popupViewLogout.findViewById(R.id.Proceed);
                btnProceedLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        BrainJuice.removeLoginUser();
                        Intent intent = new Intent(context, BrainJuice.class);
                        startActivity(intent);

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });
                popupWindowLogout.showAsDropDown(logoutQ3, 150, 50);
              }
            });

        break;

      case R.id.Q4:
        setContentView(R.layout.activity_faqinstance_adult);

        loginUser = BrainJuice.retrieveLoginUser();
        userMgr = BrainJuice.retrieveUserMgr();

        icon = (ImageView) this.findViewById(R.id.qnprofilepic);
        int jQ4 =
            getResources()
                .getIdentifier(
                    userMgr.retrieveUser(loginUser).getProfile(), "drawable", getPackageName());
        icon.setImageResource(jQ4);

        welcomeMsg = (TextView) this.findViewById(R.id.widget50);
        welcomeMsg.setText(Html.fromHtml("Hi, " + loginUser));
        checkNotification();
        TextView titleQ4 = (TextView) this.findViewById(R.id.FAQTitle);
        titleQ4.setText(Html.fromHtml("Where can I edit my profile?<br />"));

        TextView bodyQ4 = (TextView) this.findViewById(R.id.FAQBody);
        bodyQ4.setText(
            Html.fromHtml(
                "<b>Step 1</b> Tap on the “Settings” navigation tab.<br /><br />"
                    + "<b>Step 2</b> Tap on the “Edit Profile” hyperlink.<br /><br />"
                    + "<b>Step 3</b> You can change your profile picture by tapping on the icon. You can select a new profile picture from your mobile device.<br /><br />"
                    + "<b>Step 4</b> Tap the “Confirm” button."));

        ImageButton faqQ4 = (ImageButton) this.findViewById(R.id.FAQ);
        faqQ4.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultFaq.class);
                startActivity(intent);
              }
            });

        ImageButton askingQ4 = (ImageButton) this.findViewById(R.id.Answering);
        askingQ4.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultHomePage.class);
                startActivity(intent);
              }
            });
        ImageButton notificationQ4 = (ImageButton) this.findViewById(R.id.notification);
        notificationQ4.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultNotification.class);
                startActivity(intent);
              }
            });

        ImageButton qnBankQ4 = (ImageButton) this.findViewById(R.id.AnswerBank);
        qnBankQ4.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AnswerBankAccepted.class);
                startActivity(intent);
              }
            });

        ImageButton settingQ4 = (ImageButton) this.findViewById(R.id.Setting);
        settingQ4.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultSetting.class);
                startActivity(intent);
              }
            });

        final ImageButton logoutQ4 = (ImageButton) this.findViewById(R.id.Logout);
        logoutQ4.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                LayoutInflater layoutInflaterLogout =
                    (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
                View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
                final PopupWindow popupWindowLogout =
                    new PopupWindow(
                        popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                popupWindowLogout.setOutsideTouchable(false);
                popupWindowLogout.setFocusable(true);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue / 500.0f;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  e.printStackTrace();
                }

                Button btnDismissLogout = (Button) popupViewLogout.findViewById(R.id.Cancel);
                btnDismissLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        popupWindowLogout.dismiss();

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });

                Button btnProceedLogout = (Button) popupViewLogout.findViewById(R.id.Proceed);
                btnProceedLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        BrainJuice.removeLoginUser();
                        Intent intent = new Intent(context, BrainJuice.class);
                        startActivity(intent);

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });
                popupWindowLogout.showAsDropDown(logoutQ4, 150, 50);
              }
            });

        break;

      case R.id.Q5:
        setContentView(R.layout.activity_faqinstance_adult);

        loginUser = BrainJuice.retrieveLoginUser();
        userMgr = BrainJuice.retrieveUserMgr();

        icon = (ImageView) this.findViewById(R.id.qnprofilepic);
        int jQ5 =
            getResources()
                .getIdentifier(
                    userMgr.retrieveUser(loginUser).getProfile(), "drawable", getPackageName());
        icon.setImageResource(jQ5);

        welcomeMsg = (TextView) this.findViewById(R.id.widget50);
        welcomeMsg.setText(Html.fromHtml("Hi, " + loginUser));
        checkNotification();
        TextView titleQ5 = (TextView) this.findViewById(R.id.FAQTitle);
        titleQ5.setText(Html.fromHtml("Where can I change my password?<br />"));

        TextView bodyQ5 = (TextView) this.findViewById(R.id.FAQBody);
        bodyQ5.setText(
            Html.fromHtml(
                "<b>Step 1</b> Tap on the “Settings” navigation tab.<br /><br />"
                    + "<b>Step 2</b> Tap on the “Change Password” hyperlink.<br /><br />"
                    + "<b>Step 3</b> You can change your password by entering the current password, new password and confirm password.<br /><br />"
                    + "<b>Step 4</b> Tap the “Confirm” button.<br /><br />"));

        ImageButton faqQ5 = (ImageButton) this.findViewById(R.id.FAQ);
        faqQ5.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultFaq.class);
                startActivity(intent);
              }
            });

        ImageButton askingQ5 = (ImageButton) this.findViewById(R.id.Answering);
        askingQ5.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultHomePage.class);
                startActivity(intent);
              }
            });
        ImageButton notificationQ5 = (ImageButton) this.findViewById(R.id.notification);
        notificationQ5.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultNotification.class);
                startActivity(intent);
              }
            });

        ImageButton qnBankQ5 = (ImageButton) this.findViewById(R.id.AnswerBank);
        qnBankQ5.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AnswerBankAccepted.class);
                startActivity(intent);
              }
            });

        ImageButton settingQ5 = (ImageButton) this.findViewById(R.id.Setting);
        settingQ5.setOnClickListener(
            new ImageButton.OnClickListener() {
              public void onClick(View v) {
                Intent intent = new Intent(context, AdultSetting.class);
                startActivity(intent);
              }
            });

        final ImageButton logoutQ5 = (ImageButton) this.findViewById(R.id.Logout);
        logoutQ5.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                LayoutInflater layoutInflaterLogout =
                    (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
                View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
                final PopupWindow popupWindowLogout =
                    new PopupWindow(
                        popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
                popupWindowLogout.setOutsideTouchable(false);
                popupWindowLogout.setFocusable(true);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue / 500.0f;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  e.printStackTrace();
                }

                Button btnDismissLogout = (Button) popupViewLogout.findViewById(R.id.Cancel);
                btnDismissLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        popupWindowLogout.dismiss();

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });

                Button btnProceedLogout = (Button) popupViewLogout.findViewById(R.id.Proceed);
                btnProceedLogout.setOnClickListener(
                    new Button.OnClickListener() {
                      public void onClick(View v) {
                        // TODO Auto-generated method stub
                        BrainJuice.removeLoginUser();
                        Intent intent = new Intent(context, BrainJuice.class);
                        startActivity(intent);

                        try {
                          int curBrightnessValue =
                              android.provider.Settings.System.getInt(
                                  getContentResolver(),
                                  android.provider.Settings.System.SCREEN_BRIGHTNESS);
                          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                          layoutParams.screenBrightness = curBrightnessValue;
                          getWindow().setAttributes(layoutParams);
                        } catch (SettingNotFoundException e) {
                          // TODO Auto-generated catch block
                          e.printStackTrace();
                        }
                      }
                    });
                popupWindowLogout.showAsDropDown(logoutQ5, 150, 50);
              }
            });

        break;

      case R.id.Logout:
        LayoutInflater layoutInflaterLogout =
            (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
        View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
        final PopupWindow popupWindowLogout =
            new PopupWindow(popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        popupWindowLogout.setOutsideTouchable(false);
        popupWindowLogout.setFocusable(true);

        try {
          int curBrightnessValue =
              android.provider.Settings.System.getInt(
                  getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
          layoutParams.screenBrightness = curBrightnessValue;
          getWindow().setAttributes(layoutParams);
        } catch (SettingNotFoundException e) {
          e.printStackTrace();
        }

        ImageButton btnDismissLogout = (ImageButton) popupViewLogout.findViewById(R.id.Cancel);
        btnDismissLogout.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                // TODO Auto-generated method stub
                popupWindowLogout.dismiss();

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            });

        ImageButton btnProceedLogout = (ImageButton) popupViewLogout.findViewById(R.id.Proceed);
        btnProceedLogout.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                // TODO Auto-generated method stub
                BrainJuice.removeLoginUser();
                Intent intent = new Intent(context, BrainJuice.class);
                startActivity(intent);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            });
        popupWindowLogout.showAsDropDown(logout, 150, 50);

        break;
    }
  }
  @SuppressWarnings("deprecation")
  public void onClick(View v) {
    final Context context = this;

    switch (v.getId()) {
      case R.id.Asking:
        Intent intent = new Intent(context, HomePage.class);
        startActivity(intent);

        break;

      case R.id.QuestionBank:
        Intent intentQnBank = new Intent(context, ChildrenQuestionBank.class);
        startActivity(intentQnBank);
        break;

      case R.id.notification:
        Intent intentNoti = new Intent(context, ChildNotification.class);
        startActivity(intentNoti);
        break;

      case R.id.FAQ:
        Intent intentFAQ = new Intent(context, ChildFaq.class);
        startActivity(intentFAQ);
        break;

      case R.id.widget43:
        Intent intentSetting = new Intent(context, ChildSetting.class);
        startActivity(intentSetting);
        break;

      case R.id.Logout:
        LayoutInflater layoutInflaterLogout =
            (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
        View popupViewLogout = layoutInflaterLogout.inflate(R.layout.activity_logout, null);
        final PopupWindow popupWindowLogout =
            new PopupWindow(popupViewLogout, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
        popupWindowLogout.setOutsideTouchable(false);
        popupWindowLogout.setFocusable(true);

        try {
          int curBrightnessValue =
              android.provider.Settings.System.getInt(
                  getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
          WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
          layoutParams.screenBrightness = curBrightnessValue;
          getWindow().setAttributes(layoutParams);
        } catch (SettingNotFoundException e) {
          e.printStackTrace();
        }

        ImageButton btnDismissLogout = (ImageButton) popupViewLogout.findViewById(R.id.Cancel);
        btnDismissLogout.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                // TODO Auto-generated method stub
                popupWindowLogout.dismiss();

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            });

        ImageButton btnProceedLogout = (ImageButton) popupViewLogout.findViewById(R.id.Proceed);
        btnProceedLogout.setOnClickListener(
            new Button.OnClickListener() {
              public void onClick(View v) {
                // TODO Auto-generated method stub
                BrainJuice.removeLoginUser();
                Intent intent = new Intent(context, BrainJuice.class);
                startActivity(intent);

                try {
                  int curBrightnessValue =
                      android.provider.Settings.System.getInt(
                          getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
                  WindowManager.LayoutParams layoutParams = getWindow().getAttributes();
                  layoutParams.screenBrightness = curBrightnessValue;
                  getWindow().setAttributes(layoutParams);
                } catch (SettingNotFoundException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
                }
              }
            });
        popupWindowLogout.showAsDropDown(logout, 150, 50);

        break;
    }
  }
 public void set_screen_light_header() {
   WindowManager.LayoutParams lp = getWindow().getAttributes();
   lp.screenBrightness = light / 100.0f;
   getWindow().setAttributes(lp);
 }
Exemplo n.º 25
0
 void setScreenBacklight(float a) {
   WindowManager.LayoutParams lp = getWindow().getAttributes();
   lp.screenBrightness = a;
   getWindow().setAttributes(lp);
 }
Exemplo n.º 26
0
 /**
  * 设置屏幕亮度(0-255)
  *
  * @param activity
  * @param screenBrightness
  */
 public static void setScreenBrightness(Activity activity, float screenBrightness) {
   WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
   lp.screenBrightness = screenBrightness / 255f;
   activity.getWindow().setAttributes(lp);
 }
Exemplo n.º 27
0
 private void setScreenBrightness(float brightness) {
   WindowManager.LayoutParams p = getActivity().getWindow().getAttributes();
   p.screenBrightness = brightness;
   getActivity().getWindow().setAttributes(p);
 }