刘振兴 3 年 前
コミット
983960f4ff

+ 2 - 0
.idea/misc.xml

@@ -4,7 +4,9 @@
     <option name="filePathToZoomLevelMap">
       <map>
         <entry key="../../../.gradle/caches/transforms-3/dae954c5fd9608ef94a7528c5de015a2/transformed/xplibcommon/res/drawable/selector_switch_thumb.xml" value="0.12" />
+        <entry key="app/src/main/res/layout/activity_change_progress.xml" value="0.1" />
         <entry key="app/src/main/res/layout/activity_main.xml" value="0.3546195652173913" />
+        <entry key="app/src/main/res/layout/bright_activity.xml" value="0.1889564336372847" />
         <entry key="app/src/main/res/layout/display_activity.xml" value="0.20199275362318841" />
         <entry key="app/src/main/res/layout/item_checkbox.xml" value="0.20199275362318841" />
         <entry key="app/src/main/res/layout/item_connections.xml" value="0.19300911854103345" />

+ 1 - 1
app/src/main/AndroidManifest.xml

@@ -59,7 +59,7 @@
             android:configChanges="keyboardHidden|orientation|screenSize"
             android:launchMode="standard" />
         <activity
-            android:name=".Activity.VolumeBrightnessActivity"
+            android:name=".Activity.ChangeProgressActivity"
             android:configChanges="keyboardHidden|orientation|screenSize"
             android:launchMode="standard" />
         <activity

+ 4 - 0
app/src/main/java/com/xplora/xpsettings/Activity/BaseActivity.java

@@ -9,6 +9,8 @@ import android.widget.TextView;
 
 
 import com.xplora.xpsettings.R;
+import com.xplora.xpsettings.Utils.Constant;
+import com.xplora.xpsettings.Utils.ResUtils;
 
 
 public class BaseActivity extends Activity {
@@ -18,6 +20,8 @@ public class BaseActivity extends Activity {
         requestWindowFeature(Window.FEATURE_NO_TITLE);// 不显示标题
         super.onCreate(savedInstanceState);
 
+        ResUtils.initResUtils(this, Constant.PACKAGE_NAME);
+
         setFullView();
         setHardKey();
     }

+ 27 - 13
app/src/main/java/com/xplora/xpsettings/Activity/VolumeBrightnessActivity.java → app/src/main/java/com/xplora/xpsettings/Activity/ChangeProgressActivity.java

@@ -3,25 +3,25 @@ package com.xplora.xpsettings.Activity;
 import android.annotation.SuppressLint;
 import android.os.Bundle;
 import android.provider.Settings;
+import android.widget.ImageView;
 import android.widget.SeekBar;
 import android.widget.TextView;
 
 import com.xplora.xpsettings.R;
 import com.xplora.xpsettings.SettingApplication;
+import com.xplora.xpsettings.Utils.Constant;
+import com.xplora.xpsettings.Utils.ResUtils;
 
 
-public class VolumeBrightnessActivity extends BaseActivity implements SeekBar.OnSeekBarChangeListener {
+public class ChangeProgressActivity extends BaseActivity implements SeekBar.OnSeekBarChangeListener {
+    int mViewType;
     int initValue;
     int lastValue;
-    TextView mNumberText;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        setContentView(R.layout.bright_activity);
-
-        //标题
-        setWatchTitle(getResources().getStringArray(R.array.settings_title_array)[1]);
+        setContentView(R.layout.activity_change_progress);
 
         initDatas();
         initView();
@@ -36,21 +36,36 @@ public class VolumeBrightnessActivity extends BaseActivity implements SeekBar.On
     }
 
     private void initDatas() {
+        mViewType = getIntent().getIntExtra(Constant.INENT_VIEW_TYPE, 0);
         initValue = getBrightness() * 100 / 255;
     }
 
     @SuppressLint("DefaultLocale")
     private void initView() {
-        mNumberText = findViewById(R.id.numberText);
+        ImageView imageView = findViewById(R.id.icon);
+        TextView titleText = findViewById(R.id.title);
         SeekBar seekBar = findViewById(R.id.seekbar);
+
+        if (imageView != null) {
+            int imageId = ResUtils.getImageId("ic_seekbar_", mViewType);
+            imageView.setImageResource(imageId);
+        }
+
+        if (titleText != null) {
+            if (mViewType == 3) {
+                String[] stringList = getResources().getStringArray(R.array.display_title_array);
+                titleText.setText(stringList[0]);
+            } else {
+                String[] stringList = getResources().getStringArray(R.array.volume_title_array);
+                String[] soundModeList = getResources().getStringArray(R.array.soundmode_title_array);
+                String title = stringList[mViewType] + " " + soundModeList[4];
+                titleText.setText(title);
+            }
+        }
         if (seekBar != null) {
             seekBar.setProgress(initValue);
             seekBar.setOnSeekBarChangeListener(this);
         }
-        if (mNumberText != null) {
-            assert seekBar != null;
-            mNumberText.setText(String.format("%d%%", seekBar.getProgress()));
-        }
     }
 
     private int getBrightness() {
@@ -59,7 +74,7 @@ public class VolumeBrightnessActivity extends BaseActivity implements SeekBar.On
 
     private void setBrightness(int value) {
         lastValue = value;
-        Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS,  value * 255 / 100);
+        //Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS,  value * 255 / 100);
     }
 
     /*
@@ -69,7 +84,6 @@ public class VolumeBrightnessActivity extends BaseActivity implements SeekBar.On
     @Override
     public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
         if (seekBar.getId() == R.id.seekbar) {// 设置“与系统默认SeekBar对应的TextView”的值
-            mNumberText.setText(progress + "%");
             setBrightness(progress);
         }
     }

+ 2 - 1
app/src/main/java/com/xplora/xpsettings/Activity/DisplayActivity.java

@@ -48,7 +48,8 @@ public class DisplayActivity extends BaseActivity {
             Intent intent;
             switch (i) {
                 case 0:
-                    intent = new Intent(this, VolumeBrightnessActivity.class);
+                    intent = new Intent(this, ChangeProgressActivity.class);
+                    intent.putExtra(Constant.INENT_VIEW_TYPE, 3);
                     startActivity(intent);
                     break;
                 default:

+ 1 - 2
app/src/main/java/com/xplora/xpsettings/Activity/RingToneActivity.java

@@ -48,8 +48,7 @@ public class RingToneActivity extends BaseActivity {
             Intent intent;
             switch (i) {
                 case 0:
-                    intent = new Intent(this, VolumeBrightnessActivity.class);
-                    startActivity(intent);
+
                     break;
                 default:
                     break;

+ 0 - 2
app/src/main/java/com/xplora/xpsettings/Activity/SettingsActivity.java

@@ -22,8 +22,6 @@ public class SettingsActivity extends BaseActivity {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.list_activity);
 
-        ResUtils.initResUtils(this, Constant.PACKAGE_NAME);
-
         initData();
         initView();
     }

+ 3 - 9
app/src/main/java/com/xplora/xpsettings/Activity/VolumeActivity.java

@@ -46,15 +46,9 @@ public class VolumeActivity extends BaseActivity {
         listView.setAdapter(adapter);
 
         listView.setOnItemClickListener((adapterView, view, i, l) -> {
-            Intent intent;
-            switch (i) {
-                case 0:
-                    intent = new Intent(this, VolumeBrightnessActivity.class);
-                    startActivity(intent);
-                    break;
-                default:
-                    break;
-            }
+            Intent intent = new Intent(this, ChangeProgressActivity.class);
+            intent.putExtra(Constant.INENT_VIEW_TYPE, i);
+            startActivity(intent);
         });
     }
 }

+ 7 - 0
app/src/main/java/com/xplora/xpsettings/Utils/Constant.java

@@ -4,7 +4,9 @@ import android.content.Context;
 import android.provider.Settings;
 
 public class Constant {
+
     public static String PACKAGE_NAME = "com.xplora.xpsettings";
+    public static String INENT_VIEW_TYPE = "view_type";
 
     public enum CellType {
         DEFAULT,
@@ -17,4 +19,9 @@ public class Constant {
         CHECKBOX,
         REFRESH,
     }
+
+    public enum E_SEEKBAR_TYPE {
+        VOLUME,
+        BRIGHTNESS,
+    }
 }

BIN
app/src/main/res/drawable-xhdpi/ic_seekbar_0.png


BIN
app/src/main/res/drawable-xhdpi/ic_seekbar_1.png


BIN
app/src/main/res/drawable-xhdpi/ic_seekbar_2.png


BIN
app/src/main/res/drawable-xhdpi/ic_seekbar_3.png


+ 38 - 0
app/src/main/res/layout/activity_change_progress.xml

@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="@color/black"
+    android:orientation="vertical"
+    android:gravity="center_horizontal"
+    >
+
+    <ImageView
+        android:id="@+id/icon"
+        android:layout_width="41dp"
+        android:layout_height="41dp"
+        android:layout_marginTop="22dp"/>
+
+    <TextView
+        android:id="@+id/title"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginTop="4dp"
+        android:textSize="15sp"
+        android:textColor="#FFFFFFFF"
+        android:fontFamily="Roboto"
+        android:textStyle="bold"
+        />
+
+    <SeekBar
+        android:id="@+id/seekbar"
+        android:layout_width="match_parent"
+        android:layout_height="20dp"
+        android:layout_marginTop="4dp"
+        android:layout_marginStart="5dp"
+        android:layout_marginEnd="5dp"
+        android:thumb="@drawable/shape_seekbar_thumb"
+        android:progressDrawable="@drawable/selector_seekbar_bg"
+        />
+
+</LinearLayout>

+ 0 - 69
app/src/main/res/layout/bright_activity.xml

@@ -1,69 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:background="@color/black"
-    android:orientation="vertical"
-    >
-
-    <TextView
-        android:id="@+id/title"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_marginStart="8dp"
-        android:layout_marginTop="30dp"
-        android:textSize="15sp"
-        android:textColor="#FFFFFFFF"
-        android:fontFamily="Roboto"
-        android:textStyle="bold"
-        />
-
-    <TextView
-        android:id="@+id/numberText"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        android:layout_centerVertical="true"
-        android:layout_centerHorizontal="true"
-        android:textSize="20sp"
-        android:textColor="#FFFFFFFF"
-        android:fontFamily="Roboto"
-        android:textStyle="bold"
-        />
-
-    <RelativeLayout
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:layout_alignParentBottom="true"
-        android:layout_marginBottom="50dp">
-
-        <ImageView
-            android:id="@+id/bright_less"
-            android:layout_width="17.5dp"
-            android:layout_height="17.5dp"
-            android:layout_alignParentStart="true"
-            android:layout_marginStart="20dp"
-            android:src="@drawable/bright_small" />
-
-        <ImageView
-            android:id="@+id/bright_more"
-            android:layout_width="17.5dp"
-            android:layout_height="17.5dp"
-            android:layout_alignParentEnd="true"
-            android:layout_marginEnd="20dp"
-            android:src="@drawable/bright_big" />
-    </RelativeLayout>
-
-    <SeekBar
-        android:id="@+id/seekbar"
-        android:layout_width="match_parent"
-        android:layout_height="20dp"
-        android:layout_alignParentStart="true"
-        android:layout_alignParentEnd="true"
-        android:layout_alignParentBottom="true"
-        android:layout_marginStart="5dp"
-        android:layout_marginEnd="5dp"
-        android:progressBackgroundTint="@color/white"
-        android:progressTint="#FF0DA8FF"
-        android:layout_marginBottom="30dp"/>
-
-</RelativeLayout>