コード例 #1
0
 /**
  * 获取当前屏幕亮度,范围0-255
  *
  * @param context
  * @return 屏幕当前亮度值
  */
 public static int getScreenBrightness(Context context) {
   int rightnessValue = 0;
   try {
     rightnessValue =
         Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
   } catch (SettingNotFoundException e) {
     e.printStackTrace();
   }
   return rightnessValue;
 }
コード例 #2
0
 @Override
 public int getScreenBrightnessMode() throws ScreenSenseException {
   try {
     return android.provider.Settings.System.getInt(
         contentResolver, android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE);
   } catch (SettingNotFoundException e) {
     throw new ScreenSenseException(
         "Error while getting brightness mode (" + e.getMessage() + ")");
   }
 }
コード例 #3
0
ファイル: DeviceUtil.java プロジェクト: zzj180/colink
 /**
  * 获取系统休眠时间。
  *
  * @return
  */
 public static int getScreenOffTimeOut(Context context) {
   int sleepTime;
   try {
     sleepTime =
         Settings.System.getInt(context.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT);
   } catch (SettingNotFoundException e) {
     e.printStackTrace();
     sleepTime = 15 * 1000;
   }
   return sleepTime;
 }
コード例 #4
0
 /**
  * 判断是否开启了自动亮度调节
  *
  * @param context
  * @return
  */
 public static boolean isAutomicBrightness(Context context) {
   boolean automicBrightness = false;
   try {
     automicBrightness =
         Settings.System.getInt(
                 context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE)
             == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
   } catch (SettingNotFoundException e) {
     e.printStackTrace();
   }
   return automicBrightness;
 }
コード例 #5
0
 // 获取屏幕亮度值
 public int getBrightnessValue() {
   int brightnessValue = 255;
   ContentResolver resolver = mContext.getContentResolver();
   try {
     brightnessValue =
         android.provider.Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS);
   } catch (SettingNotFoundException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   return brightnessValue;
 }
コード例 #6
0
 public boolean isAutoBrightness() {
   boolean automicBrightness = false;
   try {
     final ContentResolver resolver = mContext.getContentResolver();
     automicBrightness =
         Settings.System.getInt(resolver, Settings.System.SCREEN_BRIGHTNESS_MODE)
             == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
   } catch (final SettingNotFoundException e) {
     e.printStackTrace();
   }
   return automicBrightness;
 }
コード例 #7
0
  /**
   * 当所监听的Uri发生改变时,就会回调此方法
   *
   * @param selfChange 此值意义不大 一般情况下该回调值false
   */
  @Override
  public void onChange(boolean selfChange) {
    Log.i(TAG, "-------------the airplane mode has changed-------------");

    // 系统是否处于飞行模式下
    try {
      int isAirplaneOpen =
          Settings.System.getInt(mContext.getContentResolver(), Settings.System.AIRPLANE_MODE_ON);
      Log.i(TAG, " isAirplaneOpen -----> " + isAirplaneOpen);
      mHandler.obtainMessage(MSG_AIRPLANE, isAirplaneOpen).sendToTarget();
    } catch (SettingNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #8
0
 private void LightShow() {
   // preview brightness changes at this window
   // get the current window attributes
   LayoutParams layoutpars = getWindow().getAttributes();
   // set the brightness of this window
   int light = 100;
   try {
     light = Settings.System.getInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
     layoutpars.screenBrightness =
         SettingUtils.getSetting(ComicImageViewActivity.this, "light", light) / (float) 255;
     // apply attribute changes to this window
     getWindow().setAttributes(layoutpars);
   } catch (SettingNotFoundException e) {
     e.printStackTrace();
   }
 }
コード例 #9
0
  @Override
  public void onStart() {
    super.onStart();

    try {
      float mWindowAnimation =
          Settings.System.getFloat(
              getActivity().getContentResolver(), Settings.System.WINDOW_ANIMATION_SCALE);
      mLyricsScrollView.setSmoothScrollingEnabled(mWindowAnimation > 0.0);

    } catch (SettingNotFoundException e) {
      e.printStackTrace();
    }

    IntentFilter screenstatusfilter = new IntentFilter();
    screenstatusfilter.addAction(Intent.ACTION_SCREEN_ON);
    screenstatusfilter.addAction(Intent.ACTION_SCREEN_OFF);
    getActivity().registerReceiver(mScreenTimeoutListener, screenstatusfilter);
  }
コード例 #10
0
    public void run() {
      // parser the entrance of dvb.
      Uri data = getIntent().getData();
      entrance = data.getSchemeSpecificPart();

      bootDefaultStatus = getIntent().getIntExtra("service_id", 0);

      synchronized (LoadDriveService.class) {
        // load drive and init the CA.
        nativeDrive = new NativeDrive(SplashActivity.this);
        nativeDrive.pvwareDRVInit();
        nativeDrive.CAInit();

        NativeSystemInfo SystemInfo = new NativeSystemInfo();
        SystemInfo.SystemInfoInit(SplashActivity.this);
      }
      // load player
      NativePlayer dvbPlayer = NativePlayer.getInstance();
      dvbPlayer.DVBPlayerInit(null);
      dvbPlayer.DVBPlayerSetStopMode(1);

      // parser the last play program.
      parserLastProgram();

      // process rec logic.
      synchronized (SplashActivity.class) {
        PVR_Rec_Status_t recFile = dvbPlayer.new PVR_Rec_Status_t();
        dvbPlayer.DVBPlayerPvrRecGetStatus(recFile);
        int status = recFile.getEnState();
        LogUtils.printLog(1, 3, TAG, "-----Rec File return value----->>>" + status);
        if (status == 2 || status == 3) {
          recStatus = true;
          recBundle = parserRecProgram();
        }
      }

      // delete the time.ts.
      StorageUtils util = new StorageUtils(SplashActivity.this);
      MountInfoBean mountInfoBean = util.getMobileHDDInfo();
      if (null != mountInfoBean) {
        // set ts file's name.
        String tmsFilePath = mountInfoBean.getPath() + "/time.ts";
        LogUtils.printLog(1, 3, TAG, "------time file path------->>>" + tmsFilePath);
        File file = new File(tmsFilePath);
        if (file.exists()) {
          dvbPlayer.DVBPlayerPvrRemoveFile(tmsFilePath);
        }
      }

      // get the super and parent-child's password.
      superPwd = android.provider.Settings.System.getString(getContentResolver(), "password");
      if (null == superPwd) {
        superPwd = Config.SUPER_PASSWORD;
      }

      // get programme grade.
      try {
        grade = android.provider.Settings.System.getInt(getContentResolver(), "eit_grade");
      } catch (SettingNotFoundException e) {
        // get the eit grade exception, set the default value.
        grade = 1;
        e.printStackTrace();
      }
      handler.sendEmptyMessage(Config.CONNECTION_SUCCESS);
    }
コード例 #11
0
ファイル: AdultFaq.java プロジェクト: huiwen/IS306-BrainJuice
  @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;
    }
  }
コード例 #12
0
  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
      throws JSONException {

    try {

      if (action.equals("checkValue")) {
        int getBright =
            Settings.System.getInt(
                this.cordova.getActivity().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS);
        callbackContext.success(new JSONObject().put("returnVal", getBright));
      }

      if (action.equals("checkMode")) {
        int getMode =
            Settings.System.getInt(
                this.cordova.getActivity().getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_MODE);
        callbackContext.success(new JSONObject().put("returnVal", getMode));
      }

      if (action.equals("autoEnable")) {
        Intent intent =
            new Intent(
                this.cordova.getActivity(),
                com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
        intent.putExtra("toggle mode", 1);
        this.cordova.getActivity().startActivity(intent);

        callbackContext.success(new JSONObject().put("returnVal", "enabled"));
      }

      if (action.equals("autoDisable")) {
        Intent intent =
            new Intent(
                this.cordova.getActivity(),
                com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
        intent.putExtra("toggle mode", 0);
        this.cordova.getActivity().startActivity(intent);

        callbackContext.success(new JSONObject().put("returnVal", "disabled"));
      }

      if (action.equals("autoToggle")) {
        int getMode =
            Settings.System.getInt(
                this.cordova.getActivity().getContentResolver(),
                Settings.System.SCREEN_BRIGHTNESS_MODE);
        if (getMode == 1) {
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          intent.putExtra("toggle mode", 0);
          this.cordova.getActivity().startActivity(intent);

          callbackContext.success(new JSONObject().put("returnVal", false));
        }

        if (getMode == 0) {
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          intent.putExtra("toggle mode", 1);
          this.cordova.getActivity().startActivity(intent);

          callbackContext.success(new JSONObject().put("returnVal", true));
        }
      }

      if (action.equals("value")) {
        int value = args.getJSONObject(0).getInt("value");
        float valueFloat = args.getJSONObject(0).getInt("value");
        float floater = valueFloat / 255;
        if (value > 0 && value <= 255) {
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          // in the next line 'brightness' should be a float number between 0.0 and 1.0
          intent.putExtra("brightness value", floater);
          intent.putExtra("system value", value);
          this.cordova.getActivity().startActivity(intent);

          callbackContext.success(new JSONObject().put("returnVal", value));
        } else {
          callbackContext.success(new JSONObject().put("returnVal", null));
        }
      }

      if (action.equals("up")) {
        int value = args.getJSONObject(0).getInt("step");
        int getBright =
            value
                + Settings.System.getInt(
                    this.cordova.getActivity().getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS);
        float getBrightFloat =
            value
                + Settings.System.getInt(
                    this.cordova.getActivity().getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS);
        float floater = getBrightFloat / 255;

        if ((getBright - value) == 255) {
          callbackContext.success(new JSONObject().put("returnVal", 255));
        } else if (getBright >= 255) {
          float heightFloat = 255;
          int heightBright = 255;
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          // in the next line 'brightness' should be a float number between 0.0 and 1.0
          intent.putExtra("brightness value", heightFloat);
          intent.putExtra("system value", heightBright);
          this.cordova.getActivity().startActivity(intent);
          callbackContext.success(new JSONObject().put("returnVal", heightBright));
        } else if (getBright > 0 && getBright < 255) {
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          // in the next line 'brightness' should be a float number between 0.0 and 1.0
          intent.putExtra("brightness value", floater);
          intent.putExtra("system value", getBright);
          this.cordova.getActivity().startActivity(intent);

          callbackContext.success(new JSONObject().put("returnVal", getBright));
        } else {
          callbackContext.success(new JSONObject().put("returnVal", null));
        }
      }

      if (action.equals("down")) {
        int value = args.getJSONObject(0).getInt("step");
        int getBright =
            Settings.System.getInt(
                    this.cordova.getActivity().getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS)
                - value;
        float getBrightFloat =
            Settings.System.getInt(
                    this.cordova.getActivity().getContentResolver(),
                    Settings.System.SCREEN_BRIGHTNESS)
                - value;
        float floater = getBrightFloat / 255;

        if ((getBright + value) == 1) {
          callbackContext.success(new JSONObject().put("returnVal", getBright));
        } else if (getBright <= 0) {
          float lowFloat = 1;
          int lowBright = 1;
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          // in the next line 'brightness' should be a float number between 0.0 and 1.0
          intent.putExtra("brightness value", lowFloat);
          intent.putExtra("system value", lowBright);
          this.cordova.getActivity().startActivity(intent);
          callbackContext.success(new JSONObject().put("returnVal", lowBright));
        } else if (getBright > 0 && getBright <= 255) {
          Intent intent =
              new Intent(
                  this.cordova.getActivity(),
                  com.vp9.laucher.main.vp9launcher.DummyBrightnessActivity.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // this is important
          // in the next line 'brightness' should be a float number between 0.0 and 1.0
          intent.putExtra("brightness value", floater);
          intent.putExtra("system value", getBright);
          this.cordova.getActivity().startActivity(intent);

          callbackContext.success(new JSONObject().put("returnVal", getBright));
        } else {
          callbackContext.success(new JSONObject().put("returnVal", null));
        }
      }
    } catch (SettingNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return true;
  }
コード例 #13
0
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_brightness);
    String roman = "fonts/Regular.otf";
    String medium = "fonts/Medium.otf";
    String thin = "fonts/Thin.otf";
    String bold = "fonts/Bold.otf";
    typefaceRoman = Typeface.createFromAsset(getAssets(), roman);
    typefaceMedium = Typeface.createFromAsset(getAssets(), medium);
    Typeface typefaceThin = Typeface.createFromAsset(getAssets(), thin);
    typefaceBold = Typeface.createFromAsset(getAssets(), bold);
    textStatus = (TextView) findViewById(R.id.textOk);
    textView1 = (TextView) findViewById(R.id.textView1);
    textView2 = (TextView) findViewById(R.id.textView2);

    btn_back = (Button) findViewById(R.id.buttonBack);
    btn_back.setText(R.string.app_name);
    btn_textSize = (Button) findViewById(R.id.ButtonTextSize);
    btn_textSize.setOnClickListener(this);
    btn_textBold = (Button) findViewById(R.id.ButtonTextBold);
    brtn1 = (Button) findViewById(R.id.brtn1);
    tb_bold = (ToggleButton) findViewById(R.id.ToggleButtonBoldText);
    tb_bold.setOnClickListener(this);
    Button01 = (Button) findViewById(R.id.Button01);
    Button01.setOnClickListener(this);

    mSettings = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);

    detector = new SimpleGestureFilter(this, this);

    textStatus.setText(R.string.button_brightness);
    textStatus.setTypeface(typefaceBold);
    btn_back.setTypeface(typefaceMedium);
    textView1.setTypeface(typefaceRoman);
    textView2.setTypeface(typefaceRoman);
    brtn1.setTypeface(typefaceRoman);

    Button01.setTypeface(typefaceRoman);
    btn_textSize.setTypeface(typefaceRoman);
    btn_textBold.setTypeface(typefaceRoman);

    tb_brtns = (ToggleButton) findViewById(R.id.brtntoggle);
    tb_brtns.setOnClickListener(this);
    brightbar = (SeekBar) findViewById(R.id.brightbar);
    txtPerc = (TextView) findViewById(R.id.txtPercentage);
    cResolver = getContentResolver();
    window = getWindow();
    brightbar.setMax(255);
    brightbar.setKeyProgressIncrement(1);

    try {
      // Get the current system brightness
      brightness = System.getInt(cResolver, System.SCREEN_BRIGHTNESS);
    } catch (SettingNotFoundException e) {
      // Throw an error case it couldn't be retrieved
      Log.e("Error", "Cannot access system brightness");
      e.printStackTrace();
    }
    brightbar.setProgress(brightness);

    brightbar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {
          public void onStopTrackingTouch(SeekBar seekBar) {
            // Set the system brightness using the brightness variable value
            System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
            // Get the current window attributes
            LayoutParams layoutpars = window.getAttributes();
            // Set the brightness of this window
            layoutpars.screenBrightness = brightness / (float) 255;
            // Apply attribute changes to this window
            window.setAttributes(layoutpars);
          }

          public void onStartTrackingTouch(SeekBar seekBar) {
            // Nothing handled here
          }

          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            // Set the system brightness using the brightness variable value
            System.putInt(cResolver, System.SCREEN_BRIGHTNESS, brightness);
            // Get the current window attributes
            LayoutParams layoutpars = window.getAttributes();
            // Set the brightness of this window
            layoutpars.screenBrightness = brightness / (float) 255;
            // Apply attribute changes to this window
            window.setAttributes(layoutpars);
            // Set the minimal brightness level
            // if seek bar is 20 or any value below
            if (progress <= 10) {
              // Set the brightness to 20
              brightness = 10;
            } else // brightness is greater than 20
            {
              // Set brightness variable based on the progress bar
              brightness = progress;
            }
            // Calculate the brightness percentage
            /*float perc = (brightness /(float)255)*100;
            //Set the brightness percentage
            txtPerc.setText(" "+(int)perc +" %");*/
          }
        });
  }
コード例 #14
0
  @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;
    }
  }
コード例 #15
0
  @Override
  public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(WidgetUtils.BRIGHTNESS)) {
      mSettings = context.getSharedPreferences(PREFS_NAME, 0);
      mEditor = mSettings.edit();
      String BorderOfWidgetIDs = mSettings.getString("Table_Of_Widget_IDs", "-1");
      String[] setupItemsArray = context.getResources().getStringArray(R.array.setup_items_array);
      mConverter = new Converter();
      int[] border = mConverter.String_to_tabInt(BorderOfWidgetIDs, setupItemsArray.length);
      mTheID = border[1];
      mViews = new RemoteViews(context.getPackageName(), R.layout.widget_main_layout);

      // Setting up max brightness level NEED it here
      int curBrightnessValue = 100;
      try {
        curBrightnessValue =
            android.provider.Settings.System.getInt(
                context.getContentResolver(), android.provider.Settings.System.SCREEN_BRIGHTNESS);
      } catch (SettingNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      if (curBrightnessValue < 130) {
        mState = 1;
        Settings.System.putInt(
            context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, 0);
        Settings.System.putInt(
            context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 255);
        mViews.setInt(R.id.main_one_one_one, "setAlpha", 1000);
        mViews.setInt(R.id.main_one_one_one, "setBackgroundResource", R.drawable.w_backbround_on);
      } else {
        mState = 0;
        Settings.System.putInt(
            context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, 0);
        Settings.System.putInt(context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, 30);
        mViews.setInt(R.id.main_one_one_one, "setAlpha", 40);
        mViews.setInt(R.id.main_one_one_one, "setBackgroundResource", R.drawable.w_backbround_off);
      }
      mEditor.putInt("Screen_Brightness_State", mState);
      mEditor.commit();

      ComponentName thisWidget = new ComponentName(context, MyWidgetProviderOneOne.class);
      AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);

      int[] appWidgetIds = appWidgetManager.getAppWidgetIds(thisWidget);

      for (int widgetId : appWidgetIds) {
        if (mTheID == widgetId) {
          appWidgetManager.updateAppWidget(widgetId, mViews);
          break;
        }
      }
      try {
        Intent myIntent = new Intent(context, RefreshClass.class);
        PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, myIntent, 0);
        pendingIntent.send(context, 0, myIntent);
      } catch (CanceledException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }