User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

sample_code:volume_box

This is an old revision of the document!


Volume Box

Here is the spk . Rename from apk to spk then install it .

Volume box.js
//Global variables
var music = app.GetVolume("music")
var alarm = app.GetVolume("alarm")
var notification = app.GetVolume("notification")
var system = app.GetVolume("system")
var ring = app.GetVolume("ring")
var dtmf = app.GetVolume("dtmf")
var voicecall = app.GetVolume("voicecall")
var other = app.GetVolume("other")
//Called when application is started.
function OnStart() 
{ 
       app.SetOrientation("Portrait")
       //Create a layout with objects vertically centered.
    lay = app.CreateLayout( "linear", "TopCenter,FillXY" );   
      lay.SetBackColor("#33ffff00")
     //Create Top Layout
      lay1 =app.CreateLayout("Linear","Horizontal")
    lay1.SetSize(1,.1)
    lay1.SetBackColor("#4285F4")
 //Create a text label and add it to layout.
    txt = app.CreateText( "Volume Box" );
    txt.SetTextColor("#FFFFFF")
    txt.SetTextSize( 30 );
    lay1.AddChild( txt );
    
     //Set the menu items
     menu = app.SetMenu("About,Exit")
 
     lay.AddChild(lay1)
    
      //Create a text label and add it to layout.
    txt1 = app.CreateText( "Volume Box" );
    txt1.SetTextColor("#00FF00")
    txt1.SetTextSize( 32 );
    lay.AddChild( txt1);
       //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch ); 
    skbVol.SetRange( 1.0 ); 
   
    lay.AddChild( skbVol ) 
     skbVol.SetValue(music)
      //Create a text label and add it to layout.
    txt2 = app.CreateText( "Music"+" "+music*100+"%" );
    txt2.SetTextColor("#CCFF00")
    txt2.SetTextSize( 20 );
    lay.AddChild( txt2 )
         //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch1 ); 
    skbVol.SetRange( 1.0 ); 
    skbVol.SetValue( alarm ); 
    lay.AddChild( skbVol )
    //Create a text label and add it to layout.
    txt3 = app.CreateText( "Alarm" );
    txt3.SetTextColor("#FFFF00")
    txt3.SetTextSize( 20 );
    lay.AddChild( txt3 );
  
        //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch2 ); 
    skbVol.SetRange( 1.0 ); 
    skbVol.SetValue( notification ); 
    lay.AddChild( skbVol )
       //Create a text label and add it to layout.
    txt4 = app.CreateText( "Notification" );
    txt4.SetTextColor("#00FFFF")
    txt4.SetTextSize( 20 );
    lay.AddChild( txt4 );
        //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch3 ); 
    skbVol.SetRange( 1.0 ); 
    skbVol.SetValue( system ); 
    lay.AddChild( skbVol )
       //Create a text label and add it to layout.
    txt5 = app.CreateText( "System" );
    txt5.SetTextColor("#0000FF")
    txt5.SetTextSize( 20 );
    lay.AddChild( txt5 );
        //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch4 ); 
    skbVol.SetRange( 1.0 ); 
    skbVol.SetValue( ring ); 
    lay.AddChild( skbVol )  
      //Create a text label and add it to layout.
    txt6 = app.CreateText( "Ring" );
     txt6.SetTextColor("#00FFAA")
    txt6.SetTextSize( 20 );
    lay.AddChild( txt6 );
       //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch5 ); 
    skbVol.SetRange( 1.0 ); 
    skbVol.SetValue( dtmf ); 
    lay.AddChild( skbVol )
      //Create a text label and add it to layout.
    txt7 = app.CreateText( "DTMF" );
     txt7.SetTextColor("#AAAA00")
    txt7.SetTextSize( 20 );
    lay.AddChild( txt7 );
        //Create volume bar and add to layout. 
    skbVol = app.CreateSeekBar( 0.8, -1 ); 
    //skbVol.SetMargins( 0, 0.05, 0, 0 ); 
    skbVol.SetOnTouch( skbVol_OnTouch6 ); 
    skbVol.SetRange( 1.0 ); 
    skbVol.SetValue( voicecall ); 
    lay.AddChild( skbVol )
 
    //Create a text label and add it to layout.
    txt8 = app.CreateText( "Voicecall" );
    txt8.SetTextColor("#FF0000")
    txt8.SetTextSize( 20 );
    lay.AddChild( txt8 )
    //Add layout to app.    
    app.AddLayout( lay );
   setInterval("update()")
}
 
   //Called when user touches volume bar. 
function skbVol_OnTouch( value ) 
{ 
    app.SetVolume( "music", value, value ); 
} 
 
   //Called when user touches volume bar. 
function skbVol_OnTouch1( value ) 
{ 
    app.SetVolume( "alarm", value, value );
}
 
//Called when user touches volume bar. 
function skbVol_OnTouch2( value ) 
{ 
    app.SetVolume( "notification", value, value ); 
} 
 
 
//Called when user touches volume bar. 
function skbVol_OnTouch3( value ) 
{ 
    app.SetVolume( "system", value, value ); 
} 
 
//Called when user touches volume bar. 
function skbVol_OnTouch4( value ) 
{ 
    app.SetVolume( "ring", value, value ); 
} 
 
//Called when user touches volume bar. 
function skbVol_OnTouch5( value ) 
{ 
    app.SetVolume( "dtmf", value, value ); 
} 
 
 
//Called when user touches volume bar. 
function skbVol_OnTouch6( value ) 
{ 
    app.SetVolume( "voicecall", value, value ); 
} 
//About
function About()  {
app.Alert("Created by Titus Taiti","About")
}
//Update values of volume
function update() {
var music = app.GetVolume("music").toString().slice(0,4)
var alarm = app.GetVolume("alarm").toString().slice(0,3)
var notification = app.GetVolume("notification").toString().slice(0,3)
var system = app.GetVolume("system").toString().slice(0,3)
var ring = app.GetVolume("ring").toString().slice(0,3)
var dtmf = app.GetVolume("dtmf").toString().slice(0,4)
var voicecall = app.GetVolume("voicecall").toString().slice(0,4)
txt2.SetText("Music="+" "+music*100+"%")
txt3.SetText("Alarm="+" "+alarm*100+"%")
txt4.SetText("Notification="+" "+notification*100+"%")
txt5.SetText("System="+" "+system*100+"%")
txt6.SetText("Ring="+" "+ring*100+"%")
txt7.SetText("DTMF="+" "+dtmf*100+"%")
txt8.SetText("Voicecall="+" "+voicecall*100+"%")
}
//Called when the menu key is pressed
function OnMenu(item)  {
var item;
switch(item)  {
case "About": About()
             break;
case "Exit" : app.Exit()
             break;
 default :
}}
 
/*
Note that values of notification, system, ring and dtmf all change values on adjusting one of them.
*/
sample_code/volume_box.1460923500.txt.gz · Last modified: 2016/04/18 04:05 (external edit)