-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
*.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 | ||
local.properties |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
plugins { | ||
id 'com.android.application' | ||
id 'kotlin-android' | ||
} | ||
|
||
android { | ||
compileSdkVersion 30 | ||
buildToolsVersion "30.0.2" | ||
|
||
defaultConfig { | ||
applicationId "org.springhack.stickercrap" | ||
minSdkVersion 30 | ||
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' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
kotlinOptions { | ||
jvmTarget = '1.8' | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
implementation 'com.squareup.picasso:picasso:2.8' | ||
implementation 'com.google.android:flexbox:1.0.0' | ||
implementation 'org.jsoup:jsoup:1.14.3' | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
implementation 'androidx.core:core-ktx:1.2.0' | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
implementation 'com.google.android.material:material:1.1.0' | ||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||
implementation 'androidx.wear:wear:1.0.0' | ||
testImplementation 'junit:junit:4.+' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
compileOnly 'com.google.android.wearable:wearable:2.6.0' | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.springhack.stickercrap | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("org.springhack.stickercrap", appContext.packageName) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="org.springhack.stickercrap"> | ||
|
||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
|
||
<uses-feature android:name="android.hardware.type.watch" /> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/Theme.StickerCrap" | ||
android:usesCleartextTraffic="true"> | ||
|
||
<provider | ||
android:name="androidx.core.content.FileProvider" | ||
android:authorities="org.springhack.stickercrap.fileprovider" | ||
android:exported="false" | ||
android:grantUriPermissions="true"> | ||
<meta-data | ||
android:name="android.support.FILE_PROVIDER_PATHS" | ||
android:resource="@xml/paths" /> | ||
</provider> | ||
|
||
<activity | ||
android:name=".StickerViewer" | ||
android:label="@string/title_activity_sticker_viewer" | ||
android:theme="@style/Theme.MaterialComponents.Light.Bridge" /> | ||
<activity | ||
android:name=".MainActivity" | ||
android:theme="@style/Theme.MaterialComponents.Light.Bridge"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
|
||
<category android:name="android.intent.category.LAUNCHER" /> | ||
</intent-filter> | ||
</activity> | ||
</application> | ||
|
||
</manifest> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package org.springhack.stickercrap; | ||
|
||
public class Constants { | ||
public static String FILE_PROVIDER = BuildConfig.APPLICATION_ID + ".fileprovider"; | ||
public static String USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.61 Safari/537.36"; | ||
public static String STICKER_LIST_URL = "https://sticker.weixin.qq.com/cgi-bin/mmemoticon-bin/emoticonview?oper=billboard&t=rank"; | ||
public static String[] ALLOW_PACKAGES = { | ||
"com.fluidtouch.noteshelf2", | ||
"com.samsung.android.app.notes", | ||
"com.samsung.android.spdfnote" | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package org.springhack.stickercrap; | ||
|
||
import androidx.appcompat.app.AppCompatActivity; | ||
|
||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.AdapterView; | ||
import android.widget.ListView; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.nodes.Element; | ||
import org.jsoup.select.Elements; | ||
|
||
public class MainActivity extends AppCompatActivity { | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
new Thread(new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
List<Sticker> list = new ArrayList(); | ||
Document document = | ||
Jsoup | ||
.connect(Constants.STICKER_LIST_URL) | ||
.userAgent(Constants.USER_AGENT) | ||
.referrer(Constants.STICKER_LIST_URL) | ||
.get(); | ||
Elements elements = document.select(".table_container .tbody tr .table_cell.detail"); | ||
for (Element node : elements) { | ||
Sticker sticker = new Sticker( | ||
node.select(".detail_content a.title").first().text(), | ||
node.select(".detail_content a.title").first().absUrl("href"), | ||
node.select(".detail_content .desc").first().text(), | ||
node.select("img").first().absUrl("src")); | ||
list.add(sticker); | ||
} | ||
runOnUiThread(new Runnable() { | ||
@Override | ||
public void run() { | ||
ListView list_view = findViewById(R.id.stickers_list); | ||
StickerAdapter adapter = new StickerAdapter( | ||
MainActivity.this, | ||
R.layout.stickers_list_item, | ||
list | ||
); | ||
list_view.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||
Sticker sticker = adapter.getItem(position); | ||
Intent intent = new Intent(MainActivity.this, StickerViewer.class); | ||
intent.putExtra("url", sticker.url); | ||
intent.putExtra("name", sticker.name); | ||
intent.putExtra("image", sticker.image); | ||
intent.putExtra("author", sticker.author); | ||
startActivity(intent); | ||
} | ||
}); | ||
list_view.setAdapter(adapter); | ||
} | ||
}); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
}).start(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.springhack.stickercrap; | ||
|
||
public class Sticker { | ||
|
||
public String name; | ||
public String url; | ||
public String author; | ||
public String image; | ||
|
||
public Sticker(String n, String u, String a, String i) { | ||
this.name = n; | ||
this.url = u; | ||
this.author = a; | ||
this.image = i; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.springhack.stickercrap; | ||
|
||
import android.content.Context; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ImageView; | ||
import android.widget.TextView; | ||
|
||
import com.squareup.picasso.Picasso; | ||
|
||
import java.util.List; | ||
|
||
public class StickerAdapter extends ArrayAdapter<Sticker> { | ||
|
||
private int resourceId; | ||
|
||
public StickerAdapter(Context context, int textViewResourceId, | ||
List<Sticker> objects) { | ||
super(context, textViewResourceId, objects); | ||
resourceId = textViewResourceId; | ||
} | ||
|
||
@Override | ||
public View getView(int position, View convertView, ViewGroup parent) { | ||
Sticker sticker = getItem(position); | ||
|
||
View view = LayoutInflater.from(getContext()).inflate(resourceId, null); | ||
TextView index = (TextView) view.findViewById(R.id.sticker_index); | ||
TextView name = (TextView) view.findViewById(R.id.sticker_name); | ||
TextView author = (TextView) view.findViewById(R.id.sticker_author); | ||
ImageView image = (ImageView) view.findViewById(R.id.sticker_image); | ||
|
||
index.setText(Integer.toString(position + 1)); | ||
name.setText(sticker.name); | ||
author.setText(sticker.author); | ||
Picasso.get().load(sticker.image).into(image); | ||
return view; | ||
} | ||
|
||
} |