v1.1.0 - Update Targeted Version + Enhancements + Bugfixes #1
@@ -56,6 +56,7 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
SeekBar seekBar;
|
SeekBar seekBar;
|
||||||
AudioManager audioManager;
|
AudioManager audioManager;
|
||||||
|
TextView tvSeekBar;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -210,7 +211,13 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
//(ViewManager) etMillis.getParent().remove
|
//(ViewManager) etMillis.getParent().remove
|
||||||
|
|
||||||
seekBar = findViewById(R.id.seekBar);
|
seekBar = findViewById(R.id.seekBar);
|
||||||
|
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
||||||
|
|
||||||
audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
audioManager = (AudioManager) getSystemService(AUDIO_SERVICE);
|
||||||
|
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
||||||
|
seekBar.setMax(maxVolume);
|
||||||
|
|
||||||
|
tvSeekBar = findViewById(R.id.tvSeekbar);
|
||||||
|
|
||||||
syncVolume();
|
syncVolume();
|
||||||
|
|
||||||
@@ -218,19 +225,20 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
|
||||||
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, i, AudioManager.FLAG_SHOW_UI);
|
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, i, AudioManager.FLAG_SHOW_UI);
|
||||||
|
syncVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStartTrackingTouch(SeekBar seekBar) {
|
public void onStartTrackingTouch(SeekBar seekBar) {
|
||||||
// Do Nothing
|
syncVolume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStopTrackingTouch(SeekBar seekBar) {
|
public void onStopTrackingTouch(SeekBar seekBar) {
|
||||||
// Do Nothing
|
syncVolume();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
setVolumeControlStream(AudioManager.STREAM_MUSIC);
|
|
||||||
|
|
||||||
recoverScreen();
|
recoverScreen();
|
||||||
|
|
||||||
@@ -685,11 +693,16 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void syncVolume() {
|
public void syncVolume() {
|
||||||
int maxVolume = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
|
String tag = TAG + "syncVolume";
|
||||||
seekBar.setMax(maxVolume);
|
if (DEBUG) Log.d(tag, "Starting");
|
||||||
|
|
||||||
int currVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
int currVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
|
||||||
seekBar.setProgress(currVolume);
|
seekBar.setProgress(currVolume);
|
||||||
|
|
||||||
|
String volume = getString(R.string.tvSeekBar) + seekBar.getProgress() + "/" + seekBar.getMax();
|
||||||
|
tvSeekBar.setText(volume);
|
||||||
|
|
||||||
|
if (DEBUG) Log.d(tag, "Finished");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -158,13 +158,27 @@
|
|||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
<SeekBar
|
<RelativeLayout
|
||||||
android:id="@+id/seekBar"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@id/tblButtons"
|
android:layout_below="@id/tblButtons"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true">
|
||||||
android:layout_marginVertical="@dimen/activity_vertical_margin"
|
<SeekBar
|
||||||
android:layout_centerHorizontal="true"/>
|
android:id="@+id/seekBar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="@dimen/activity_vertical_margin"
|
||||||
|
android:layout_centerInParent="true"
|
||||||
|
android:indeterminate="false"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvSeekbar"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@id/seekBar"
|
||||||
|
android:layout_centerHorizontal="true"
|
||||||
|
android:text="@string/tvSeekBar"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
@@ -35,4 +35,6 @@
|
|||||||
<string name="action_millis">Enable Millisecs</string>
|
<string name="action_millis">Enable Millisecs</string>
|
||||||
<string name="action_enable_ads">Enable Ads</string>
|
<string name="action_enable_ads">Enable Ads</string>
|
||||||
<string name="action_exit">Exit</string>
|
<string name="action_exit">Exit</string>
|
||||||
|
|
||||||
|
<string name="tvSeekBar">Media Volume: </string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Reference in New Issue
Block a user