|
@@ -5,6 +5,8 @@ import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
import android.provider.Settings;
|
|
|
import android.util.Log;
|
|
|
+import android.view.View;
|
|
|
+import android.widget.ImageButton;
|
|
|
import android.widget.ImageView;
|
|
|
import android.widget.SeekBar;
|
|
|
import android.widget.TextView;
|
|
@@ -14,17 +16,23 @@ import com.xplora.xpsettings.Data.DataManager;
|
|
|
import com.xplora.xpsettings.Utils.Constant;
|
|
|
import com.xplora.xpsettings.Utils.ResUtils;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
-public class ChangeProgressActivity extends BaseActivity implements SeekBar.OnSeekBarChangeListener {
|
|
|
+public class ChangeProgressActivity extends BaseActivity {
|
|
|
int mViewType = 0;
|
|
|
-
|
|
|
int curValue = 0;
|
|
|
int maxValue = 100;
|
|
|
int minValue = 0;
|
|
|
+ int[] mDisplayArray = {20, 40, 60, 80, 100};
|
|
|
+ int[] mVoiceArray = {0, 30, 60, 100};
|
|
|
|
|
|
- private ImageView mImageView = null;
|
|
|
+ private ImageView mIcon = null;
|
|
|
+ private ImageView mSubButton = null;
|
|
|
+ private ImageView mAddButton = null;
|
|
|
+ private TextView mProgressText = null;
|
|
|
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@@ -56,10 +64,19 @@ public class ChangeProgressActivity extends BaseActivity implements SeekBar.OnSe
|
|
|
|
|
|
@SuppressLint("DefaultLocale")
|
|
|
private void initView() {
|
|
|
- mImageView = findViewById(R.id.icon);
|
|
|
- TextView titleText = findViewById(R.id.title);
|
|
|
- SeekBar seekBar = findViewById(R.id.seekbar);
|
|
|
+ mIcon = findViewById(R.id.icon);
|
|
|
+ mProgressText = findViewById(R.id.progressText);
|
|
|
+ mSubButton = findViewById(R.id.subButton);
|
|
|
+ mAddButton = findViewById(R.id.addButton);
|
|
|
+ mSubButton.setOnClickListener( v -> clickSubButton());
|
|
|
+ mAddButton.setOnClickListener( v -> clickAddButton());
|
|
|
+ initTitle();
|
|
|
+ changeImage();
|
|
|
+ changeProgress();
|
|
|
+ }
|
|
|
|
|
|
+ private void initTitle() {
|
|
|
+ TextView titleText = findViewById(R.id.title);
|
|
|
if (titleText != null) {
|
|
|
if (mViewType == 3) {
|
|
|
String[] stringList = ResUtils.getStringArray("display_title_array_", 4);
|
|
@@ -71,64 +88,58 @@ public class ChangeProgressActivity extends BaseActivity implements SeekBar.OnSe
|
|
|
titleText.setText(title);
|
|
|
}
|
|
|
}
|
|
|
- if (seekBar != null) {
|
|
|
- seekBar.setMin(0);
|
|
|
- seekBar.setMax(maxValue);
|
|
|
- seekBar.setProgress(curValue);
|
|
|
- seekBar.setOnSeekBarChangeListener(this);
|
|
|
- }
|
|
|
-
|
|
|
- changeImage();
|
|
|
}
|
|
|
|
|
|
private void changeImage() {
|
|
|
- if (mImageView == null)
|
|
|
+ if (mIcon == null)
|
|
|
return;
|
|
|
if (mViewType == 3) {
|
|
|
int imageId = ResUtils.getImageId("ic_seekbar_", mViewType);
|
|
|
- mImageView.setImageResource(imageId);
|
|
|
+ mIcon.setImageResource(imageId);
|
|
|
} else {
|
|
|
int index = curValue <= 0 ? 0 : 2;
|
|
|
int imageId = ResUtils.getImageId("ic_seekbar_", index);
|
|
|
- mImageView.setImageResource(imageId);
|
|
|
+ mIcon.setImageResource(imageId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * SeekBar滚动时的回调函数
|
|
|
- */
|
|
|
- @SuppressLint("SetTextI18n")
|
|
|
- @Override
|
|
|
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
|
- if (progress <= minValue) {
|
|
|
- progress = minValue;
|
|
|
- seekBar.setProgress(progress);
|
|
|
- }
|
|
|
- Log.d(TAG, "onProgressChanged: mViewType:" + mViewType + " progress: " + progress);
|
|
|
+ private void changeProgress() {
|
|
|
|
|
|
- curValue = progress;
|
|
|
- if (mViewType == 3) {
|
|
|
- DataManager.setBrightness(progress);
|
|
|
- } else {
|
|
|
- DataManager.setVolume(mViewType, progress);
|
|
|
- }
|
|
|
-
|
|
|
- changeImage();
|
|
|
-
|
|
|
- int value = mViewType == 3 ? curValue : (curValue * 100 / maxValue);
|
|
|
- Intent intent = new Intent();
|
|
|
- intent.putExtra(Constant.INTENT_VIEW_TYPE, mViewType);
|
|
|
- intent.putExtra(Constant.INTENT_RESULT_VALUE, value);
|
|
|
- setResult(RESULT_OK, intent);
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onStartTrackingTouch(SeekBar seekBar) {
|
|
|
+ private void clickSubButton() {
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public void onStopTrackingTouch(SeekBar seekBar) {
|
|
|
+ private void clickAddButton() {
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+// /*
|
|
|
+// * SeekBar滚动时的回调函数
|
|
|
+// */
|
|
|
+// @SuppressLint("SetTextI18n")
|
|
|
+// @Override
|
|
|
+// public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
|
|
|
+// if (progress <= minValue) {
|
|
|
+// progress = minValue;
|
|
|
+// seekBar.setProgress(progress);
|
|
|
+// }
|
|
|
+// Log.d(TAG, "onProgressChanged: mViewType:" + mViewType + " progress: " + progress);
|
|
|
+//
|
|
|
+// curValue = progress;
|
|
|
+// if (mViewType == 3) {
|
|
|
+// DataManager.setBrightness(progress);
|
|
|
+// } else {
|
|
|
+// DataManager.setVolume(mViewType, progress);
|
|
|
+// }
|
|
|
+//
|
|
|
+// changeImage();
|
|
|
+//
|
|
|
+// int value = mViewType == 3 ? curValue : (curValue * 100 / maxValue);
|
|
|
+// Intent intent = new Intent();
|
|
|
+// intent.putExtra(Constant.INTENT_VIEW_TYPE, mViewType);
|
|
|
+// intent.putExtra(Constant.INTENT_RESULT_VALUE, value);
|
|
|
+// setResult(RESULT_OK, intent);
|
|
|
+// }
|
|
|
}
|