updated myip
This commit is contained in:
commit
2275d5b36d
13
.gitignore
vendored
13
.gitignore
vendored
@ -1 +1,14 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
|
BIN
.gradle/6.1.1/fileChanges/last-build.bin
Normal file
BIN
.gradle/6.1.1/fileChanges/last-build.bin
Normal file
Binary file not shown.
BIN
.gradle/6.1.1/fileHashes/fileHashes.lock
Normal file
BIN
.gradle/6.1.1/fileHashes/fileHashes.lock
Normal file
Binary file not shown.
0
.gradle/6.1.1/gc.properties
Normal file
0
.gradle/6.1.1/gc.properties
Normal file
1
.idea/.gitignore
vendored
1
.idea/.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
|
||||
# Default ignored files
|
||||
/workspace.xml
|
21
.idea/gradle.xml
Normal file
21
.idea/gradle.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="testRunner" value="PLATFORM" />
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleJvm" value="1.8" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
<option value="$PROJECT_DIR$/app" />
|
||||
</set>
|
||||
</option>
|
||||
<option name="resolveModulePerSourceSet" value="false" />
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
25
.idea/jarRepositories.xml
Normal file
25
.idea/jarRepositories.xml
Normal file
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="BintrayJCenter" />
|
||||
<option name="name" value="BintrayJCenter" />
|
||||
<option name="url" value="https://jcenter.bintray.com/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="Google" />
|
||||
<option name="name" value="Google" />
|
||||
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
9
.idea/misc.xml
Normal file
9
.idea/misc.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||
</component>
|
||||
<component name="ProjectType">
|
||||
<option name="id" value="Android" />
|
||||
</component>
|
||||
</project>
|
12
.idea/runConfigurations.xml
Normal file
12
.idea/runConfigurations.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RunConfigurationProducerService">
|
||||
<option name="ignoredProducers">
|
||||
<set>
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||
</set>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
1
app/.gitignore
vendored
Normal file
1
app/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/build
|
34
app/build.gradle
Normal file
34
app/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.paulbsd.myip"
|
||||
minSdkVersion 19
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
|
||||
|
||||
}
|
21
app/proguard-rules.pro
vendored
Normal file
21
app/proguard-rules.pro
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
28
app/src/main/AndroidManifest.xml
Normal file
28
app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.paulbsd.myip">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme">
|
||||
<activity
|
||||
<<<<<<< HEAD:paulbsdmyip/src/main/AndroidManifest.xml
|
||||
android:name=".main"
|
||||
=======
|
||||
android:name="com.paulbsd.myip.MainActivity"
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce:app/src/main/AndroidManifest.xml
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
98
app/src/main/java/com/paulbsd/myip/MainActivity.java
Normal file
98
app/src/main/java/com/paulbsd/myip/MainActivity.java
Normal file
@ -0,0 +1,98 @@
|
||||
package com.paulbsd;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
<<<<<<< HEAD:paulbsdmyip/src/com/paulbsd/main.java
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
=======
|
||||
import android.widget.Toolbar;
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce:app/src/main/java/com/paulbsd/myip/MainActivity.java
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
String url = "https://ipinfo.io/json";
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final TextView public_ip = (TextView) findViewById(R.id.PublicIP);
|
||||
final TextView hostname = (TextView) findViewById(R.id.Hostname);
|
||||
final TextView city = (TextView) findViewById(R.id.City);
|
||||
final TextView org = (TextView) findViewById(R.id.Org);
|
||||
|
||||
Button but = (Button) findViewById(R.id.but);
|
||||
|
||||
<<<<<<< HEAD:paulbsdmyip/src/com/paulbsd/main.java
|
||||
this.updateIpInfo(publicip, hostname, city, org);
|
||||
=======
|
||||
this.updateIpInfo(public_ip,hostname,city,org);
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce:app/src/main/java/com/paulbsd/myip/MainActivity.java
|
||||
|
||||
but.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
<<<<<<< HEAD:paulbsdmyip/src/com/paulbsd/main.java
|
||||
updateIpInfo(publicip, hostname, city, org);
|
||||
=======
|
||||
updateIpInfo(public_ip,hostname,city,org);
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce:app/src/main/java/com/paulbsd/myip/MainActivity.java
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setSupportActionBar(Toolbar toolbar) {
|
||||
}
|
||||
|
||||
public void updateIpInfo(TextView public_ip, TextView hostname, TextView city, TextView org) {
|
||||
try {
|
||||
getIpInfo ipinfo = new getIpInfo(this.url);
|
||||
public_ip.setText(ipinfo.getIp());
|
||||
hostname.setText(ipinfo.getHostname());
|
||||
city.setText(ipinfo.getCity());
|
||||
org.setText(ipinfo.getOrg());
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
// Inflate the menu; this adds items to the action bar if it is present.
|
||||
getMenuInflater().inflate(R.menu.menu_main, menu);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
// Handle action bar item clicks here. The action bar will
|
||||
// automatically handle clicks on the Home/Up button, so long
|
||||
// as you specify a parent activity in AndroidManifest.xml.
|
||||
int id = item.getItemId();
|
||||
|
||||
//noinspection SimplifiableIfStatement
|
||||
if (id == R.id.action_settings) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
94
app/src/main/java/com/paulbsd/myip/getIpInfo.java
Normal file
94
app/src/main/java/com/paulbsd/myip/getIpInfo.java
Normal file
@ -0,0 +1,94 @@
|
||||
package com.paulbsd;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class getIpInfo {
|
||||
|
||||
// Main URL
|
||||
String url;
|
||||
|
||||
// IP attributes
|
||||
private String ip = "undef";
|
||||
private String hostname = "undef";
|
||||
private String city = "undef";
|
||||
private String org = "undef";
|
||||
|
||||
// Response
|
||||
String resp;
|
||||
|
||||
<<<<<<< HEAD:paulbsdmyip/src/com/paulbsd/getIpInfo.java
|
||||
getIpInfo(String url) throws Exception {
|
||||
=======
|
||||
public getIpInfo(String url) throws Exception
|
||||
{
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce:app/src/main/java/com/paulbsd/myip/getIpInfo.java
|
||||
this.url = url;
|
||||
|
||||
System.out.println("Initiating connection to " + this.url);
|
||||
|
||||
this.resp = getHTML(this.url);
|
||||
JSONObject reader = new JSONObject(resp);
|
||||
|
||||
System.out.println("Terminating connection to " + this.url);
|
||||
|
||||
try {
|
||||
this.ip = reader.getString("ip");
|
||||
this.hostname = reader.getString("hostname");
|
||||
this.city = reader.getString("city");
|
||||
this.org = reader.getString("org");
|
||||
} catch (JSONException jse) {
|
||||
System.out.println(jse);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getHTML(String urlToRead) throws IOException {
|
||||
StringBuilder result = new StringBuilder();
|
||||
URL url = new URL(urlToRead);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String line;
|
||||
while ((line = rd.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
rd.close();
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:paulbsdmyip/src/com/paulbsd/getIpInfo.java
|
||||
String getIp() {
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
String getHostname() {
|
||||
return this.hostname;
|
||||
}
|
||||
|
||||
String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
String getOrg() {
|
||||
=======
|
||||
public String getIp()
|
||||
{
|
||||
return this.ip;
|
||||
}
|
||||
|
||||
public String getHostname()
|
||||
{
|
||||
return this.hostname;
|
||||
}
|
||||
|
||||
public String getCity()
|
||||
{
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public String getOrg()
|
||||
{
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce:app/src/main/java/com/paulbsd/myip/getIpInfo.java
|
||||
return this.org;
|
||||
}
|
||||
}
|
30
app/src/main/res/layout/activity_main.xml
Normal file
30
app/src/main/res/layout/activity_main.xml
Normal file
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context="com.paulbsd.myip.MainActivity">
|
||||
<android.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
<!--<androidx.appcompat.widget.ActionMenuView
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
|
||||
</androidx.appcompat.widget.ActionMenuView>-->
|
||||
|
||||
<include
|
||||
layout="@layout/content_main"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_width="match_parent" />
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
148
app/src/main/res/layout/content_main.xml
Normal file
148
app/src/main/res/layout/content_main.xml
Normal file
@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#FFFFFF"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="com.paulbsd.myip.MainActivity"
|
||||
tools:showIn="@layout/activity_main">
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/notification_large_icon_height"
|
||||
android:layout_marginBottom="@dimen/notification_large_icon_height"
|
||||
tools:ignore="PrivateResource">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@string/ip"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="14pt"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/PublicIP"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="14pt" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/host"
|
||||
android:textSize="14pt"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Hostname"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="10pt" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/city"
|
||||
android:textSize="14pt"
|
||||
android:textStyle="bold" />
|
||||
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/City"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="10pt" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/provider"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="14pt"
|
||||
android:textStyle="bold" />
|
||||
</TableRow>
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Org"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="textStart"
|
||||
android:textSize="10pt" />
|
||||
</TableRow>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/app_header"
|
||||
android:textSize="16pt" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/but"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:text="@string/button_refresh" />
|
||||
|
||||
</RelativeLayout>
|
10
app/src/main/res/menu/menu_main.xml
Normal file
10
app/src/main/res/menu/menu_main.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:context="com.paulbsd.myip.MainActivity">
|
||||
<item
|
||||
android:id="@+id/action_settings"
|
||||
android:title="@string/action_settings"
|
||||
android:orderInCategory="100"
|
||||
app:showAsAction="never" />
|
||||
</menu>
|
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.3 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
8
app/src/main/res/values-v21/styles.xml
Normal file
8
app/src/main/res/values-v21/styles.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<resources>
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
</style>
|
||||
</resources>
|
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
6
app/src/main/res/values-w820dp/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
|
||||
(such as screen margins) for screens with more than 820dp of available width. This
|
||||
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
|
||||
<dimen name="activity_horizontal_margin">64dp</dimen>
|
||||
</resources>
|
6
app/src/main/res/values/colors.xml
Normal file
6
app/src/main/res/values/colors.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
6
app/src/main/res/values/dimens.xml
Normal file
6
app/src/main/res/values/dimens.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<resources>
|
||||
<!-- Default screen margins, per the Android Design guidelines. -->
|
||||
<dimen name="activity_horizontal_margin">16dp</dimen>
|
||||
<dimen name="activity_vertical_margin">16dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
</resources>
|
11
app/src/main/res/values/strings.xml
Normal file
11
app/src/main/res/values/strings.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
<string name="app_name">PaulBSD ShowMyIP</string>
|
||||
<string name="action_settings">Settings</string>
|
||||
<string name="button_refresh">Refresh</string>
|
||||
<string name="app_header">Public IP</string>
|
||||
<string name="ip_address_resolution_service_url">https://ipinfo.io/json</string>
|
||||
<string name="ip">IP</string>
|
||||
<string name="host">Host</string>
|
||||
<string name="city">City</string>
|
||||
<string name="provider">Provider</string>
|
||||
</resources>
|
17
app/src/main/res/values/styles.xml
Normal file
17
app/src/main/res/values/styles.xml
Normal file
@ -0,0 +1,17 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
<style name="AppTheme.NoActionBar">
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
</style>
|
||||
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
|
||||
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
|
||||
|
||||
</resources>
|
24
build.gradle
Normal file
24
build.gradle
Normal file
@ -0,0 +1,24 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
buildscript {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:4.0.0"
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
3
gradlew
vendored
3
gradlew
vendored
@ -161,7 +161,10 @@ save () {
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> 64e9f08dbcd4adcd0791cbe73337bd2b3822ecce
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.json.JSONObject;
|
||||
public class getIpInfo {
|
||||
|
||||
// Main URL
|
||||
private String url;
|
||||
String url;
|
||||
|
||||
// IP attributes
|
||||
private String ip = "undef";
|
||||
@ -15,7 +15,7 @@ public class getIpInfo {
|
||||
private String org = "undef";
|
||||
|
||||
// Response
|
||||
private String resp;
|
||||
String resp;
|
||||
|
||||
getIpInfo(String url) throws Exception {
|
||||
this.url = url;
|
||||
@ -37,7 +37,7 @@ public class getIpInfo {
|
||||
}
|
||||
}
|
||||
|
||||
static String getHTML(String urlToRead) throws IOException {
|
||||
public static String getHTML(String urlToRead) throws IOException {
|
||||
StringBuilder result = new StringBuilder();
|
||||
URL url = new URL(urlToRead);
|
||||
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.paulbsd;
|
||||
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.StrictMode;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
@ -10,8 +11,14 @@ import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
String url = "https://ipinfo.io/json";
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@ -23,7 +30,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
|
||||
setSupportActionBar(toolbar);
|
||||
|
||||
final TextView publicip = (TextView) findViewById(R.id.PublicIP);
|
||||
final TextView public_ip = (TextView) findViewById(R.id.PublicIP);
|
||||
final TextView hostname = (TextView) findViewById(R.id.Hostname);
|
||||
final TextView city = (TextView) findViewById(R.id.City);
|
||||
final TextView org = (TextView) findViewById(R.id.Org);
|
||||
@ -40,10 +47,13 @@ public class MainActivity extends AppCompatActivity {
|
||||
});
|
||||
}
|
||||
|
||||
public void updateIpInfo(TextView publicip, TextView hostname, TextView city, TextView org) {
|
||||
private void setSupportActionBar(Toolbar toolbar) {
|
||||
}
|
||||
|
||||
public void updateIpInfo(TextView public_ip, TextView hostname, TextView city, TextView org) {
|
||||
try {
|
||||
getIpInfo ipinfo = new getIpInfo("https://ipinfo.io/json");
|
||||
publicip.setText(ipinfo.getIp());
|
||||
getIpInfo ipinfo = new getIpInfo(this.url);
|
||||
public_ip.setText(ipinfo.getIp());
|
||||
hostname.setText(ipinfo.getHostname());
|
||||
city.setText(ipinfo.getCity());
|
||||
org.setText(ipinfo.getOrg());
|
||||
|
@ -4,19 +4,20 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
android:background="#FFFFFF"
|
||||
android:paddingLeft="@dimen/activity_horizontal_margin"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingTop="@dimen/activity_vertical_margin"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior"
|
||||
android:paddingRight="@dimen/activity_horizontal_margin"
|
||||
android:paddingBottom="@dimen/activity_vertical_margin"
|
||||
tools:context="com.paulbsd.myip.MainActivity"
|
||||
tools:showIn="@layout/activity_main">
|
||||
|
||||
<TableLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="@dimen/notification_large_icon_height"
|
||||
android:layout_marginBottom="@dimen/notification_large_icon_height"
|
||||
android:layout_marginTop="@dimen/notification_large_icon_height">
|
||||
tools:ignore="PrivateResource">
|
||||
|
||||
<TableRow
|
||||
android:layout_width="match_parent"
|
||||
|
Loading…
Reference in New Issue
Block a user