-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #738 from zhongdingjun/master
- Loading branch information
Showing
8 changed files
with
215 additions
and
22 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/src/main/java/edu/hzuapps/androidworks/homeworks/com1314080901146/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="edu.hzuapps.androidworks.homeworks.com1314080901146" | ||
android:versionCode="1" | ||
android:versionName="1.0"> | ||
<application android:icon="@drawable/myicon" android:label="@string/app_name"> | ||
<activity android:name=".Com1314080901146Activity" | ||
android:label="@string/app_name"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
</application> | ||
|
||
|
||
</manifest> |
180 changes: 158 additions & 22 deletions
180
...in/java/edu/hzuapps/androidworks/homeworks/com1314080901146/Com1314080901146Activity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,177 @@ | ||
package edu.hzuapps.androidworks.homeworks.com1314080901146; | ||
|
||
import android.app.Activity; | ||
import android.app.AlertDialog; | ||
import android.content.DialogInterface; | ||
import android.content.res.Resources; | ||
import android.graphics.drawable.Drawable; | ||
import android.hardware.SensorManager; | ||
import android.os.Bundle; | ||
import android.support.v7.app.ActionBarActivity; | ||
import android.view.View; | ||
import android.widget.Button; | ||
import android.view.Menu; | ||
import android.view.MenuItem; | ||
import android.view.MotionEvent; | ||
import android.view.Window; | ||
import android.view.WindowManager; | ||
import android.widget.LinearLayout; | ||
import android.widget.Toast; | ||
|
||
import edu.hzuapps.androidworks.R; | ||
import edu.hzuapps.androidworks.homeworks.BackActivity; | ||
import edu.hzuapps.androidworks.homeworks.com1314080901146.R; | ||
|
||
public class Com1314080901146Activity extends BackActivity { | ||
public class Com1314080901146Activity extends Activity { | ||
|
||
private LinearLayout mylayout; | ||
private Resources myColor; | ||
private int li; | ||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
public void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_com123456); | ||
HideStatusBase(); | ||
setContentView(R.layout.main); | ||
|
||
|
||
Button closeBtn = (Button) findViewById(R.id.button_close); | ||
closeBtn.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View view) { | ||
finish(); | ||
} | ||
}); | ||
mylayout=(LinearLayout)findViewById(R.id.mylayout); | ||
|
||
SetColor(R.color.white); | ||
|
||
li=0; | ||
SetBright(1.0f); | ||
|
||
} | ||
|
||
|
||
|
||
@Override | ||
protected void onStart() { | ||
super.onStart(); | ||
public boolean onTouchEvent(MotionEvent event){ | ||
|
||
openOptionsMenu(); | ||
return false; | ||
} | ||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
public boolean onCreateOptionsMenu(Menu menu){ | ||
super.onCreateOptionsMenu(menu); | ||
getMenuInflater().inflate(R.menu.menu, menu); | ||
|
||
return true; | ||
} | ||
|
||
|
||
@Override | ||
protected void onStop() { | ||
super.onStop(); | ||
public boolean onOptionsItemSelected(MenuItem item){ | ||
switch(item.getItemId()) | ||
{ | ||
|
||
case R.id.setcolor: | ||
|
||
selectColor(); | ||
return true; | ||
case R.id.setbright: | ||
selectBright(); | ||
|
||
return true; | ||
case R.id.seteffer: | ||
|
||
finish(); | ||
return true; | ||
|
||
} | ||
return false; | ||
} | ||
|
||
public void selectColor() | ||
{ | ||
final String[] items = {"White", "Red", "Black","Yellow","Pink"}; | ||
new AlertDialog.Builder(this) | ||
.setTitle("Select Color") | ||
.setItems(items, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int item) { | ||
Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show(); | ||
switch (item) { | ||
case 0: | ||
SetColor(R.color.white); | ||
break; | ||
case 1: | ||
SetColor(R.color.red); | ||
break; | ||
case 2: | ||
SetColor(R.color.black); | ||
break; | ||
case 3: | ||
SetColor(R.color.yellow); | ||
break; | ||
case 4: | ||
SetColor(R.color.fs); | ||
break; | ||
default: | ||
SetColor(R.color.white); | ||
break; | ||
} | ||
} | ||
}).show(); | ||
} | ||
|
||
|
||
public void selectBright() | ||
{ | ||
final String[] items = {"100%", "75%", "50%","25%","10%"}; | ||
new AlertDialog.Builder(this) | ||
.setTitle("Select Brightness") | ||
.setSingleChoiceItems(items, li, new DialogInterface.OnClickListener() { | ||
public void onClick(DialogInterface dialog, int item) { | ||
Toast.makeText(getApplicationContext(), items[item],Toast.LENGTH_SHORT).show(); | ||
li=item; | ||
switch (item) { | ||
case 0: | ||
SetBright(1.0F); | ||
break; | ||
case 1: | ||
SetBright(0.75F); | ||
break; | ||
case 2: | ||
SetBright(0.5F); | ||
break; | ||
case 3: | ||
SetBright(0.25F); | ||
break; | ||
case 4: | ||
SetBright(0.1F); | ||
break; | ||
default: | ||
SetBright(1.0F); | ||
break; | ||
} | ||
dialog.cancel(); | ||
} | ||
}).show(); | ||
} | ||
|
||
|
||
|
||
|
||
private void HideStatusBase() | ||
{ | ||
requestWindowFeature(Window.FEATURE_NO_TITLE); | ||
int flag=WindowManager.LayoutParams.FLAG_FULLSCREEN; | ||
Window myWindow=this.getWindow(); | ||
myWindow.setFlags(flag,flag); | ||
} | ||
|
||
|
||
|
||
private void SetColor(int color_1) | ||
{ | ||
myColor = getBaseContext().getResources(); | ||
Drawable color_M = myColor.getDrawable(color_1); | ||
mylayout.setBackgroundDrawable(color_M); | ||
|
||
} | ||
|
||
|
||
private void SetBright(float light) | ||
{ | ||
WindowManager.LayoutParams lp=getWindow().getAttributes(); | ||
lp.screenBrightness=light; | ||
getWindow().setAttributes(lp); | ||
|
||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="white">#FFFFFF</color> | ||
<color name="yellow">#FFD700</color> | ||
<color name="red">#FF0000</color> | ||
<color name="fs">#FF34B3</color> | ||
<color name="black">#000000</color> | ||
</resources> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<menu | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item android:id="@+id/setcolor" | ||
android:title="@string/setcolor" | ||
/> | ||
<item android:id="@+id/setbright" | ||
android:title="@string/setbright" | ||
/> | ||
<item android:id="@+id/seteffer" | ||
android:title="@string/seteffer" | ||
/> | ||
|
||
</menu> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<color name="white">#FFFFFF</color> | ||
<color name="yellow">#FFD700</color> | ||
<color name="red">#FF0000</color> | ||
<color name="fs">#FF34B3</color> | ||
<color name="black">#000000</color> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<string name="hello">你好</string> | ||
<string name="app_name">钟定钧的手电筒</string> | ||
<string name="setcolor">Change Color</string> | ||
<string name="setbright">Change Brightness</string> | ||
<string name="seteffer">Quit</string> | ||
|
||
</resources> |