Skip to content

Commit 23efbac

Browse files
author
hussienalrubaye
committed
add pockemon game
1 parent 8f2abf0 commit 23efbac

File tree

83 files changed

+1616
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1616
-0
lines changed

Diff for: Assets/mapApp/bulbasaur.png

13.4 KB
Loading

Diff for: Assets/mapApp/charmander.png

16.3 KB
Loading

Diff for: Assets/mapApp/mario.png

17.4 KB
Loading

Diff for: Assets/mapApp/squirtle.png

15.6 KB
Loading

Diff for: MyCurrentLocationApp/.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
*.iml
2+
.gradle
3+
/local.properties
4+
/.idea/workspace.xml
5+
/.idea/libraries
6+
.DS_Store
7+
/build
8+
/captures
9+
.externalNativeBuild

Diff for: MyCurrentLocationApp/.idea/encodings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: MyCurrentLocationApp/.idea/gradle.xml

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: MyCurrentLocationApp/.idea/misc.xml

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: MyCurrentLocationApp/.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: MyCurrentLocationApp/.idea/runConfigurations.xml

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: MyCurrentLocationApp/app/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

Diff for: MyCurrentLocationApp/app/build.gradle

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
apply plugin: 'com.android.application'
2+
3+
android {
4+
compileSdkVersion 25
5+
buildToolsVersion "25.0.3"
6+
defaultConfig {
7+
applicationId "com.hussein.mycurrentlocation"
8+
minSdkVersion 16
9+
targetSdkVersion 25
10+
versionCode 1
11+
versionName "1.0"
12+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
13+
}
14+
buildTypes {
15+
release {
16+
minifyEnabled false
17+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18+
}
19+
}
20+
}
21+
22+
dependencies {
23+
compile fileTree(dir: 'libs', include: ['*.jar'])
24+
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
25+
exclude group: 'com.android.support', module: 'support-annotations'
26+
})
27+
compile 'com.android.support:appcompat-v7:25.3.1'
28+
testCompile 'junit:junit:4.12'
29+
compile 'com.google.android.gms:play-services-maps:10.2.4'
30+
}

Diff for: MyCurrentLocationApp/app/proguard-rules.pro

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /Users/hussienalrubaye/Library/Android/sdk/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
18+
19+
# Uncomment this to preserve the line number information for
20+
# debugging stack traces.
21+
#-keepattributes SourceFile,LineNumberTable
22+
23+
# If you keep the line number information, uncomment this to
24+
# hide the original source file name.
25+
#-renamesourcefileattribute SourceFile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.hussein.mycurrentlocation;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumentation test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
@Test
20+
public void useAppContext() throws Exception {
21+
// Context of the app under test.
22+
Context appContext = InstrumentationRegistry.getTargetContext();
23+
24+
assertEquals("com.hussein.mycurrentlocation", appContext.getPackageName());
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<resources>
2+
<!--
3+
TODO: Before you run your application, you need a Google Maps API key.
4+
5+
To get one, follow this link, follow the directions and press "Create" at the end:
6+
7+
https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=76:A0:7B:52:24:16:38:F1:0F:B6:D3:CF:8F:6B:85:5F:92:91:69:DC%3Bcom.hussein.mycurrentlocation
8+
9+
You can also add your credentials to an existing key, using these values:
10+
11+
Package name:
12+
76:A0:7B:52:24:16:38:F1:0F:B6:D3:CF:8F:6B:85:5F:92:91:69:DC
13+
14+
SHA-1 certificate fingerprint:
15+
76:A0:7B:52:24:16:38:F1:0F:B6:D3:CF:8F:6B:85:5F:92:91:69:DC
16+
17+
Alternatively, follow the directions here:
18+
https://developers.google.com/maps/documentation/android/start#get-key
19+
20+
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
21+
string in this file.
22+
-->
23+
<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">
24+
AIzaSyDtV4_eo9zhPpAhSxNp9hOl0lLXix5abQw
25+
</string>
26+
</resources>
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.hussein.mycurrentlocation">
4+
<!--
5+
The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
6+
Google Maps Android API v2, but you must specify either coarse or fine
7+
location permissions for the 'MyLocation' functionality.
8+
-->
9+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
10+
11+
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
12+
android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round"
13+
android:supportsRtl="true" android:theme="@style/AppTheme">
14+
<!--
15+
The API key for Google Maps-based APIs is defined as a string resource.
16+
(See the file "res/values/google_maps_api.xml").
17+
Note that the API key is linked to the encryption key used to sign the APK.
18+
You need a different API key for each encryption key, including the release key that is used to
19+
sign the APK for publishing.
20+
You can define the keys for the debug and release targets in src/debug/ and src/release/.
21+
-->
22+
<meta-data android:name="com.google.android.geo.API_KEY"
23+
android:value="@string/google_maps_key" />
24+
25+
<activity android:name=".MapsActivity" android:label="@string/title_activity_maps">
26+
<intent-filter>
27+
<action android:name="android.intent.action.MAIN" />
28+
29+
<category android:name="android.intent.category.LAUNCHER" />
30+
</intent-filter>
31+
</activity>
32+
</application>
33+
34+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
package com.hussein.mycurrentlocation;
2+
3+
import android.content.Context;
4+
import android.content.pm.PackageManager;
5+
import android.location.Location;
6+
import android.location.LocationListener;
7+
import android.location.LocationManager;
8+
import android.os.Build;
9+
import android.support.v4.app.ActivityCompat;
10+
import android.support.v4.app.FragmentActivity;
11+
import android.os.Bundle;
12+
import android.widget.Toast;
13+
14+
import com.google.android.gms.maps.CameraUpdateFactory;
15+
import com.google.android.gms.maps.GoogleMap;
16+
import com.google.android.gms.maps.OnMapReadyCallback;
17+
import com.google.android.gms.maps.SupportMapFragment;
18+
import com.google.android.gms.maps.model.LatLng;
19+
import com.google.android.gms.maps.model.MarkerOptions;
20+
21+
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
22+
23+
private GoogleMap mMap;
24+
25+
@Override
26+
protected void onCreate(Bundle savedInstanceState) {
27+
super.onCreate(savedInstanceState);
28+
setContentView(R.layout.activity_maps);
29+
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
30+
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
31+
.findFragmentById(R.id.map);
32+
mapFragment.getMapAsync(this);
33+
34+
35+
CheckUserPermsions();
36+
}
37+
38+
39+
/**
40+
* Manipulates the map once available.
41+
* This callback is triggered when the map is ready to be used.
42+
* This is where we can add markers or lines, add listeners or move the camera. In this case,
43+
* we just add a marker near Sydney, Australia.
44+
* If Google Play services is not installed on the device, the user will be prompted to install
45+
* it inside the SupportMapFragment. This method will only be triggered once the user has
46+
* installed Google Play services and returned to the app.
47+
*/
48+
@Override
49+
public void onMapReady(GoogleMap googleMap) {
50+
mMap = googleMap;
51+
}
52+
53+
void CheckUserPermsions(){
54+
if ( Build.VERSION.SDK_INT >= 23){
55+
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) !=
56+
PackageManager.PERMISSION_GRANTED ){
57+
requestPermissions(new String[]{
58+
android.Manifest.permission.ACCESS_FINE_LOCATION},
59+
REQUEST_CODE_ASK_PERMISSIONS);
60+
return ;
61+
}
62+
}
63+
64+
LocationListner();// init the contact list
65+
66+
}
67+
//get acces to location permsion
68+
final private int REQUEST_CODE_ASK_PERMISSIONS = 123;
69+
70+
71+
72+
@Override
73+
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
74+
switch (requestCode) {
75+
case REQUEST_CODE_ASK_PERMISSIONS:
76+
if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
77+
LocationListner();// init the contact list
78+
} else {
79+
// Permission Denied
80+
Toast.makeText( this,"your message" , Toast.LENGTH_SHORT)
81+
.show();
82+
}
83+
break;
84+
default:
85+
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
86+
}
87+
}
88+
89+
90+
void LocationListner(){
91+
LocationListener locationListener = new MyLocationListener(this);
92+
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
93+
94+
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 35000, 10, locationListener);
95+
96+
97+
myThread m_thread= new myThread();
98+
m_thread.start();
99+
}
100+
101+
class myThread extends Thread{
102+
103+
public void run(){
104+
while (true){
105+
try{
106+
runOnUiThread(new Runnable() {
107+
@Override
108+
public void run() {
109+
mMap.clear();
110+
111+
// Add a marker in Sydney and move the camera
112+
LatLng sydney = new LatLng(MyLocationListener.location.getLatitude(), MyLocationListener.location.getLongitude());
113+
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
114+
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
115+
116+
}
117+
});
118+
119+
120+
Thread.sleep(1000);
121+
}catch (Exception ex){}
122+
}
123+
}
124+
}
125+
}

0 commit comments

Comments
 (0)