Skip to content

Commit

Permalink
Updated ui and built a release apk.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlynxZhou committed Mar 10, 2019
1 parent 3678244 commit b3f30e9
Show file tree
Hide file tree
Showing 39 changed files with 883 additions and 227 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -12,12 +12,12 @@ Currently under developing.

Some icons are from following links, thanks to authors.

<div>Icons made by <a href="https://www.flaticon.com/authors/daniel-bruce" title="Daniel Bruce">Daniel Bruce</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>

<div>Icons made by <a href="https://www.freepik.com/" title="Freepik">Freepik</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>

<div>Icons made by <a href="https://www.flaticon.com/authors/hanan" title="Hanan">Hanan</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>

<div>Icons made by <a href="https://www.flaticon.com/authors/eleonor-wang" title="Eleonor Wang">Eleonor Wang</a> from <a href="https://www.flaticon.com/" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>

# License

Apache-2.0
2 changes: 1 addition & 1 deletion app/build.gradle
Expand Up @@ -7,7 +7,7 @@ android {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file added app/release/app-release.apk
Binary file not shown.
1 change: 1 addition & 0 deletions app/release/output.json
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1,"versionName":"1.0.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}]
24 changes: 17 additions & 7 deletions app/src/main/AndroidManifest.xml
@@ -1,15 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="xyz.alynx.livewallpaper">

<uses-permission android:name="android.permission.SET_WALLPAPER" />

<!-- Tell the system this app requires OpenGL ES 3.0. -->
<uses-feature android:glEsVersion="0x00030000" android:required="true" />

<uses-feature
android:glEsVersion="0x00030000"
android:required="true" />
<uses-feature
android:name="android.software.live_wallpaper"
android:required="true" />
<application
android:name="xyz.alynx.livewallpaper.LWApplication"
android:name=".LWApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
Expand All @@ -22,8 +24,17 @@
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
<activity android:name=".AboutActivity"
android:parentActivityName=".MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
<service
android:name=".GLWallpaperService"
android:permission="android.permission.BIND_WALLPAPER">
Expand All @@ -35,5 +46,4 @@
android:resource="@xml/wallpaper" />
</service>
</application>

</manifest>
Binary file not shown.
51 changes: 51 additions & 0 deletions app/src/main/java/xyz/alynx/livewallpaper/AboutActivity.java
@@ -0,0 +1,51 @@
/**
* Copyright 2019 Alynx Zhou
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package xyz.alynx.livewallpaper;

import android.content.pm.PackageManager;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.method.ScrollingMovementMethod;
import android.widget.TextView;

public class AboutActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
Toolbar toolbar = findViewById(R.id.about_toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
TextView appDetail = findViewById(R.id.app_detail);
appDetail.setMovementMethod(new ScrollingMovementMethod());
TextView appVersion = findViewById(R.id.app_version);
String versionName = null;
try {
versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
} catch (PackageManager.NameNotFoundException e) {
versionName = "Unknown";
}
appVersion.setText(String.format(
getResources().getText(R.string.app_version).toString(), versionName
));
}
}
56 changes: 41 additions & 15 deletions app/src/main/java/xyz/alynx/livewallpaper/CardAdapter.java
@@ -1,13 +1,30 @@
/**
* Copyright 2019 Alynx Zhou
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package xyz.alynx.livewallpaper;

import android.app.WallpaperManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.support.v7.widget.CardView;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -19,51 +36,54 @@

public class CardAdapter extends RecyclerView.Adapter<CardViewHolder> {
private final static String TAG = "CardAdapter";
private Context context = null;
private List<WallpaperCard> cards = null;
private boolean removable = false;

public CardAdapter(Context context, List<WallpaperCard> cards) {
super();
this.context = context;
this.cards = cards;
}

@NonNull
@Override
public CardViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.wallpaper_card, viewGroup, false);
View itemView = LayoutInflater.from(viewGroup.getContext()).inflate(
R.layout.wallpaper_card, viewGroup, false
);
return new CardViewHolder(itemView);
}

@Override
public void onBindViewHolder(@NonNull final CardViewHolder cardViewHolder, int i) {
WallpaperCard card = cards.get(cardViewHolder.getLayoutPosition());
Log.d(TAG, "Bound card: " + cardViewHolder.getLayoutPosition());
cardViewHolder.name.setText(card.getName());
cardViewHolder.path.setText(card.getPath());
if (card.getType() == WallpaperCard.Type.INTERNAL) {
cardViewHolder.internal.setVisibility(View.VISIBLE);
} else {
cardViewHolder.internal.setVisibility(View.INVISIBLE);
cardViewHolder.internal.setVisibility(View.GONE);
}
cardViewHolder.thumbnail.setImageBitmap(card.getThumbnail());
if (removable && card.getType() != WallpaperCard.Type.INTERNAL) {
if (removable && card.isRemovable()) {
cardViewHolder.removeButton.setVisibility(View.VISIBLE);
} else {
cardViewHolder.removeButton.setVisibility(View.INVISIBLE);
cardViewHolder.removeButton.setVisibility(View.GONE);
}
cardViewHolder.removeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
removeCard(cardViewHolder.getLayoutPosition());
}
});
cardViewHolder.cardView.setOnClickListener(new View.OnClickListener() {
cardViewHolder.thumbnail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d(TAG, "Card " + cardViewHolder.getLayoutPosition() + " clicked");
List<WallpaperCard> cards = LWApplication.getCards();
LWApplication.setActivateWallpaperCard(cards.get(cardViewHolder.getLayoutPosition()));
Log.d(TAG, "Set activate WallpaperCard to " + cardViewHolder.getLayoutPosition());
LWApplication.setActivateWallpaperCard(
cards.get(cardViewHolder.getLayoutPosition())
);
Intent intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
intent.putExtra(
WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
Expand All @@ -81,12 +101,16 @@ public int getItemCount() {

public void addCard(int position, WallpaperCard card) {
cards.add(position, card);
notifyDataSetChanged();
notifyItemInserted(position);
}

public void removeCard(int position) {
notifyItemRemoved(position);
context.getContentResolver().releasePersistableUriPermission(
Uri.parse(cards.get(position).getPath()),
Intent.FLAG_GRANT_READ_URI_PERMISSION
);
cards.remove(position);
notifyDataSetChanged();
}

public void setRemovable(boolean removable) {
Expand All @@ -102,19 +126,21 @@ public boolean isRemovable() {
class CardViewHolder extends RecyclerView.ViewHolder {
private final static String TAG = "CardViewHolder";
public CardView cardView = null;
public ImageView thumbnail = null;
public TextView name = null;
public TextView path = null;
public TextView internal = null;
public ImageView thumbnail = null;
public Button internal = null;
public Button removeButton = null;

public CardViewHolder(View view) {
super(view);
cardView = view.findViewById(R.id.wallpaper_card);
thumbnail = view.findViewById(R.id.thumbnail);
name = view.findViewById(R.id.name);
name.setMovementMethod(new ScrollingMovementMethod());
path = view.findViewById(R.id.path);
path.setMovementMethod(new ScrollingMovementMethod());
internal = view.findViewById(R.id.internal);
thumbnail = view.findViewById(R.id.thumbnail);
removeButton = view.findViewById(R.id.remove_button);
}
}

0 comments on commit b3f30e9

Please sign in to comment.