-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
159 changed files
with
21,570 additions
and
85 deletions.
There are no files selected for viewing
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,85 +1 @@ | ||
# Built application files | ||
*.apk | ||
*.aar | ||
*.ap_ | ||
*.aab | ||
|
||
# Files for the ART/Dalvik VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# Generated files | ||
bin/ | ||
gen/ | ||
out/ | ||
# Uncomment the following line in case you need and you don't have the release build type files in your app | ||
# release/ | ||
|
||
# Gradle files | ||
.gradle/ | ||
build/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Proguard folder generated by Eclipse | ||
proguard/ | ||
|
||
# Log Files | ||
*.log | ||
|
||
# Android Studio Navigation editor temp files | ||
.navigation/ | ||
|
||
# Android Studio captures folder | ||
captures/ | ||
|
||
# IntelliJ | ||
*.iml | ||
.idea/workspace.xml | ||
.idea/tasks.xml | ||
.idea/gradle.xml | ||
.idea/assetWizardSettings.xml | ||
.idea/dictionaries | ||
.idea/libraries | ||
# Android Studio 3 in .gitignore file. | ||
.idea/caches | ||
.idea/modules.xml | ||
# Comment next line if keeping position of elements in Navigation Editor is relevant for you | ||
.idea/navEditor.xml | ||
|
||
# Keystore files | ||
# Uncomment the following lines if you do not want to check your keystore files in. | ||
#*.jks | ||
#*.keystore | ||
|
||
# External native build folder generated in Android Studio 2.2 and later | ||
.externalNativeBuild | ||
.cxx/ | ||
|
||
# Google Services (e.g. APIs or Firebase) | ||
# google-services.json | ||
|
||
# Freeline | ||
freeline.py | ||
freeline/ | ||
freeline_project_description.json | ||
|
||
# fastlane | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots | ||
fastlane/test_output | ||
fastlane/readme.md | ||
|
||
# Version control | ||
vcs.xml | ||
|
||
# lint | ||
lint/intermediates/ | ||
lint/generated/ | ||
lint/outputs/ | ||
lint/tmp/ | ||
# lint/reports/ | ||
*/build |
Binary file not shown.
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,25 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
|
||
|
||
defaultConfig { | ||
applicationId "ru.maximoff.zasample" | ||
minSdkVersion 14 | ||
targetSdkVersion 28 | ||
versionCode 1 | ||
versionName "1.0" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
api project(':zipalign') | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
} |
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,31 @@ | ||
# Add project specific ProGuard rules here. | ||
# By default, the flags in this file are appended to flags specified | ||
# in C:\tools\adt-bundle-windows-x86_64-20131030\sdk/tools/proguard/proguard-android.txt | ||
# You can edit the include path and order by changing the proguardFiles | ||
# directive in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# Add any project specific keep options here: | ||
|
||
# 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 *; | ||
#} | ||
-keepattributes SourceFile, LineNumberTable | ||
|
||
-renamesourcefileattribute SourceFile | ||
-repackageclasses | ||
|
||
-dontwarn android.arch.** | ||
-dontwarn android.lifecycle.** | ||
-keep class android.arch.** { *; } | ||
-keep class android.lifecycle.** { *; } | ||
|
||
-dontwarn androidx.arch.** | ||
-dontwarn androidx.lifecycle.** | ||
-keep class androidx.arch.** { *; } | ||
-keep class androidx.lifecycle.** { *; } |
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,25 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<manifest | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="ru.maximoff.zasample"> | ||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> | ||
<application | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:label="@string/app_name" | ||
android:theme="@style/AppTheme" | ||
android:resizeableActivity="true"> | ||
<activity | ||
android:name=".MainActivity" | ||
android:configChanges="orientation|screenSize" | ||
android:windowSoftInputMode="stateHidden|adjustResize" | ||
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> |
123 changes: 123 additions & 0 deletions
123
ZipAlign-sample/src/main/java/ru/maximoff/zasample/MainActivity.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 |
---|---|---|
@@ -0,0 +1,123 @@ | ||
package ru.maximoff.zasample; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.content.pm.PackageManager; | ||
import android.net.Uri; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.view.View; | ||
import android.view.View.OnClickListener; | ||
import android.widget.Button; | ||
import android.widget.CheckBox; | ||
import android.widget.EditText; | ||
import android.widget.Toast; | ||
import java.io.File; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import ru.maximoff.zipalign.ZipAligner; | ||
import android.preference.PreferenceManager; | ||
import android.content.SharedPreferences; | ||
|
||
public class MainActivity extends Activity { | ||
private final int REQUEST = 1010; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.main); | ||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
final EditText path = findViewById(R.id.mainEditText1); | ||
path.setText(prefs.getString("saved_path", "")); | ||
final CheckBox sharedLibs = findViewById(R.id.mainCheckBox1); | ||
Button align = findViewById(R.id.mainButton1); | ||
Button check = findViewById(R.id.mainButton2); | ||
OnClickListener listener = new OnClickListener() { | ||
@Override | ||
public void onClick(View p1) { | ||
String filePath = path.getText().toString(); | ||
if (filePath.equals("")) { | ||
return; | ||
} | ||
File file = new File(filePath); | ||
if (!file.exists()) { | ||
st("File " + filePath + " not found!"); | ||
return; | ||
} | ||
prefs.edit().putString("saved_path", filePath).commit(); | ||
boolean resultOk; | ||
switch (p1.getId()) { | ||
case R.id.mainButton1: | ||
int p = file.getName().lastIndexOf("."); | ||
String target; | ||
if (p > 0){ | ||
target = file.getParent() + "/" + file.getName().substring(0, p) +"_aligned" + file.getName().substring(p); | ||
} else { | ||
target = filePath + "_aligned"; | ||
} | ||
resultOk = ZipAligner.align(filePath, target, ZipAligner.DEFAULT_LEVEL, sharedLibs.isChecked()); | ||
path.setText(target); | ||
break; | ||
|
||
case R.id.mainButton2: | ||
resultOk = ZipAligner.isAligned(filePath, ZipAligner.DEFAULT_LEVEL, sharedLibs.isChecked()); | ||
break; | ||
|
||
default: | ||
resultOk = false; | ||
break; | ||
} | ||
st("Result: " + String.valueOf(resultOk)); | ||
} | ||
}; | ||
align.setOnClickListener(listener); | ||
check.setOnClickListener(listener); | ||
checkPerm(this, new String[]{"READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"}); | ||
} | ||
|
||
@Override | ||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { | ||
switch (requestCode) { | ||
case REQUEST: | ||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | ||
st("Permissions granted!"); | ||
} else if (!shouldShowRequestPermissionRationale(permissions[0])) { | ||
st("This app needs permissions!"); | ||
goToSettings(); | ||
finish(); | ||
} else { | ||
checkPerm(this, new String[]{"READ_EXTERNAL_STORAGE", "WRITE_EXTERNAL_STORAGE"}); | ||
} | ||
break; | ||
|
||
default: | ||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||
} | ||
} | ||
|
||
private void goToSettings() { | ||
Intent myAppSettings = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + getPackageName())); | ||
startActivity(myAppSettings); | ||
} | ||
|
||
public void st(String s) { | ||
Toast.makeText(this, s, Toast.LENGTH_SHORT).show(); | ||
} | ||
|
||
public void checkPerm(Activity act, String[] groups) { | ||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||
List<String> permissions = new ArrayList<>(); | ||
for (String permission : groups) { | ||
permission = "android.permission." + permission; | ||
if (act.checkSelfPermission(permission) != PackageManager.PERMISSION_GRANTED) { | ||
permissions.add(permission); | ||
} | ||
} | ||
if (permissions.isEmpty()) { | ||
return; | ||
} | ||
String[] request = permissions.toArray(new String[permissions.size()]); | ||
act.requestPermissions(request, REQUEST); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
ZipAlign-sample/src/main/res/drawable-v24/ic_launcher_foreground.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,34 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:aapt="http://schemas.android.com/aapt" | ||
android:width="108dp" | ||
android:height="108dp" | ||
android:viewportWidth="108" | ||
android:viewportHeight="108"> | ||
<path | ||
android:fillType="evenOdd" | ||
android:pathData="M32,64C32,64 38.39,52.99 44.13,50.95C51.37,48.37 70.14,49.57 70.14,49.57L108.26,87.69L108,109.01L75.97,107.97L32,64Z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000"> | ||
<aapt:attr name="android:fillColor"> | ||
<gradient | ||
android:endX="78.5885" | ||
android:endY="90.9159" | ||
android:startX="48.7653" | ||
android:startY="61.0927" | ||
android:type="linear"> | ||
<item | ||
android:color="#44000000" | ||
android:offset="0.0" /> | ||
<item | ||
android:color="#00000000" | ||
android:offset="1.0" /> | ||
</gradient> | ||
</aapt:attr> | ||
</path> | ||
<path | ||
android:fillColor="#FFFFFF" | ||
android:fillType="nonZero" | ||
android:pathData="M66.94,46.02L66.94,46.02C72.44,50.07 76,56.61 76,64L32,64C32,56.61 35.56,50.11 40.98,46.06L36.18,41.19C35.45,40.45 35.45,39.3 36.18,38.56C36.91,37.81 38.05,37.81 38.78,38.56L44.25,44.05C47.18,42.57 50.48,41.71 54,41.71C57.48,41.71 60.78,42.57 63.68,44.05L69.11,38.56C69.84,37.81 70.98,37.81 71.71,38.56C72.44,39.3 72.44,40.45 71.71,41.19L66.94,46.02ZM62.94,56.92C64.08,56.92 65,56.01 65,54.88C65,53.76 64.08,52.85 62.94,52.85C61.8,52.85 60.88,53.76 60.88,54.88C60.88,56.01 61.8,56.92 62.94,56.92ZM45.06,56.92C46.2,56.92 47.13,56.01 47.13,54.88C47.13,53.76 46.2,52.85 45.06,52.85C43.92,52.85 43,53.76 43,54.88C43,56.01 43.92,56.92 45.06,56.92Z" | ||
android:strokeWidth="1" | ||
android:strokeColor="#00000000" /> | ||
</vector> |
Oops, something went wrong.