Skip to content

Commit

Permalink
Merge pull request #1 from jeffshee/v1.3
Browse files Browse the repository at this point in the history
V1.3
  • Loading branch information
jeffshee authored Feb 7, 2019
2 parents 87afe7c + bcf9585 commit cf3489b
Show file tree
Hide file tree
Showing 34 changed files with 402 additions and 86 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
3 changes: 3 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "io.github.jeffshee.linestickerkeyboard"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.2"
versionCode 2
versionName "1.3"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
Expand All @@ -21,6 +21,7 @@ android {

repositories {
jcenter()
maven { url "https://jitpack.io" }
}

dependencies {
Expand All @@ -38,4 +39,5 @@ dependencies {
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'io.github.jeffshee.apng2gif:apng2gif:1.2'
implementation "com.github.nekocode:Badge:2.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestBuilder;
Expand Down Expand Up @@ -70,10 +71,21 @@ public boolean onResourceReady(Drawable resource, Object model, Target<Drawable>
@Override
public void onClick(View view) {
if (service != null) {
service.postSticker((Sticker) stickerViewHolder.itemView.getTag(), saveHistory());
service.postSticker((Sticker) stickerViewHolder.itemView.getTag(), saveHistory(), false);
}
}
});
// LongClick to force sending stickers as (A)PNG files
stickerViewHolder.imageView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
if (service != null) {
Toast.makeText(context, context.getString(R.string.force_png), Toast.LENGTH_SHORT).show();
service.postSticker((Sticker) stickerViewHolder.itemView.getTag(), saveHistory(), true);
}
return true;
}
});
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;

import com.bumptech.glide.Glide;

Expand Down Expand Up @@ -64,10 +66,24 @@ public void onClick(View view) {
public void onClick(View view) {
int i = stickerPacks.indexOf((StickerPack) stickerViewHolder.itemView.getTag());
Toast.makeText(context,
context.getString(R.string.store_id)+" "+
context.getString(R.string.store_id) + " " +
stickerPacks.get(i).getStoreId(), Toast.LENGTH_SHORT).show();
}
});
stickerViewHolder.toggle.setChecked(stickerPacks.get(i).getVisible());
stickerViewHolder.toggle.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
int i = stickerPacks.indexOf((StickerPack) stickerViewHolder.itemView.getTag());
stickerPacks.get(i).setVisible(isChecked);
SharedPrefHelper.saveNewStickerPacks(context, stickerPacks);
// Notify IMServer only
Intent intent = new Intent();
intent.setAction(BROADCAST_ACTION);
intent.putExtra("message", "refresh");
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
}
});
}

private void delete(final int index) {
Expand Down Expand Up @@ -135,12 +151,14 @@ private class ListViewHolder extends RecyclerView.ViewHolder {
private ImageView imageView;
private TextView textView;
private Button button;
private ToggleButton toggle;

ListViewHolder(View itemView) {
super(itemView);
imageView = itemView.findViewById(R.id.imageView);
textView = itemView.findViewById(R.id.textView);
button = itemView.findViewById(R.id.btnDelete);
toggle = itemView.findViewById(R.id.toggle_visibility);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import io.github.jeffshee.apng2gif.Apng2Gif;
import io.github.jeffshee.linestickerkeyboard.Model.Sticker;
import io.github.jeffshee.linestickerkeyboard.Model.StickerPack;
import io.github.jeffshee.linestickerkeyboard.Util.Apng2GifCustom;
import io.github.jeffshee.linestickerkeyboard.Util.SharedPrefHelper;

public class FetchService extends IntentService {
Expand All @@ -50,7 +50,7 @@ public class FetchService extends IntentService {
NotificationManagerCompat notificationManager;
File pngDir;
File gifDir;
Apng2Gif apng2Gif;
Apng2GifCustom apng2GifCustom;

public FetchService() {
super("FetchService");
Expand All @@ -77,7 +77,7 @@ protected void onHandleIntent(Intent intent) {
notificationManager = NotificationManagerCompat.from(this);
pngDir = new File(getFilesDir(), "png");
gifDir = new File(getFilesDir(), "gif");
apng2Gif = new Apng2Gif();
apng2GifCustom = new Apng2GifCustom();

if (intent != null) {
final String action = intent.getAction();
Expand Down Expand Up @@ -240,7 +240,7 @@ private boolean convert() {
for (int id = firstId; id < firstId + count; id++) {
png = new File(pngDir, String.valueOf(id) + ".png");
gif = new File(gifDir, String.valueOf(id) + ".gif");
apng2Gif.start(png, gif);
apng2GifCustom.start(png, gif);
builder.setContentTitle(String.format(Locale.getDefault(),
getString(R.string.fetch_converting) + " (%d/%d)", id - firstId + 1, count))
.setSmallIcon(R.mipmap.ic_launcher)
Expand All @@ -256,4 +256,5 @@ private void send() {
intent.putExtra("message", "add");
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class IMService extends InputMethodService {
/* ImageKeyboard Google Samples
* https://github.com/googlesamples/android-CommitContentSampleIME/
*/
public void postSticker(Sticker sticker, boolean saveHistory) {
public void postSticker(Sticker sticker, boolean saveHistory, boolean forcePng) {
// Launch Main Activity for disclaimer
if (!SharedPrefHelper.getDisclaimerStatus(this)) {
Toast.makeText(this, getString(R.string.disclaimer_toast), Toast.LENGTH_SHORT).show();
Expand All @@ -57,13 +57,13 @@ public void postSticker(Sticker sticker, boolean saveHistory) {
} else {
boolean isPng = isCommitContentSupported(MIME_TYPE_PNG);
boolean isGif = isCommitContentSupported(MIME_TYPE_GIF);
if (sticker.getType() == Sticker.Type.STATIC) {
if (sticker.getType() == Sticker.Type.STATIC || forcePng) {
if (isPng) {
File file = FileHelper.getFile(this, sticker);
File file = FileHelper.getPngFile(this, sticker.getId());
doCommitContent(file, MIME_TYPE_PNG);
} else {
Toast.makeText(this, getString(R.string.not_supported), Toast.LENGTH_SHORT).show();
File file = FileHelper.getFile(this, sticker);
File file = FileHelper.getPngFile(this, sticker.getId());
createShareIntent(file, MIME_TYPE_PNG);
}
} else {
Expand Down Expand Up @@ -153,7 +153,6 @@ public View onCreateInputView() {

@Override
public void onStartInput(EditorInfo attribute, boolean restarting) {

super.onStartInput(attribute, restarting);
}

Expand Down Expand Up @@ -220,8 +219,9 @@ private class Receiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
if (stickerKeyboardView != null)
stickerKeyboardView.refreshViewPager(context);
// Restart everything, thanks for this.
// https://stackoverflow.com/questions/20288655/how-to-restart-oncreateinputview
setInputView(onCreateInputView());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,31 @@
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;
import android.support.v4.content.LocalBroadcastManager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.Toast;

import java.util.ArrayList;

import cn.nekocode.badge.BadgeDrawable;
import io.github.jeffshee.linestickerkeyboard.Model.HistoryPack;
import io.github.jeffshee.linestickerkeyboard.Model.Sticker;
import io.github.jeffshee.linestickerkeyboard.Util.SharedPrefHelper;

import static io.github.jeffshee.linestickerkeyboard.FetchService.BROADCAST_ACTION;

public class MainActivity extends AppCompatActivity implements AdapterView.OnItemClickListener {

private static final String TRACKER = "https://github.com/jeffshee/LINEStickerKeyboard/issues";
private static final String HP = "https://github.com/jeffshee/LINEStickerKeyboard";
private static final String README = "https://github.com/jeffshee/LINEStickerKeyboard/blob/master/README.md";

Activity activity = this;

Expand All @@ -37,6 +43,14 @@ protected void onCreate(Bundle savedInstanceState) {
listView.setAdapter(new ArrayAdapter<>(this,
android.R.layout.simple_list_item_1, getResources().getStringArray(R.array.main_activity_list)));
listView.setOnItemClickListener(this);
ImageView footer = findViewById(R.id.footer);
footer.setImageDrawable(new
BadgeDrawable.Builder()
.type(BadgeDrawable.TYPE_WITH_TWO_TEXT_COMPLEMENTARY)
.badgeColor(getResources().getColor(R.color.md_deep_purple_900))
.text1(getString(R.string.app_name))
.text2(BuildConfig.VERSION_NAME)
.build());
}

@Override
Expand Down Expand Up @@ -74,6 +88,11 @@ private void clearHistory() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
SharedPrefHelper.saveNewHistoryPack(activity, new HistoryPack(new ArrayList<Sticker>()));
// Notify IMServer only
Intent intent = new Intent();
intent.setAction(BROADCAST_ACTION);
intent.putExtra("message", "refresh");
LocalBroadcastManager.getInstance(activity).sendBroadcast(intent);
}
})
.setNegativeButton(getString(R.string.negative_cancel), null);
Expand All @@ -87,13 +106,13 @@ private void feedback() {
}

private void about() {
Uri uri = Uri.parse(HP);
Uri uri = Uri.parse(README);
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}

private void disclaimer() {
if(!SharedPrefHelper.getDisclaimerStatus(this)){
if (!SharedPrefHelper.getDisclaimerStatus(this)) {
final AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setCancelable(false).setTitle(getString(R.string.disclaimer))
.setMessage(getString(R.string.disclaimer_text))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ public class StickerPack {
private int count;
private int storeId;
private String title;
private boolean visible;

public StickerPack(Sticker firstSticker, int count, int storeId, String title) {
this.firstSticker = firstSticker;
this.count = count;
this.storeId = storeId;
this.title = title;
this.visible = true;
}

public int getFirstId() {
Expand Down Expand Up @@ -40,4 +42,12 @@ public int getStoreId() {
public String getTitle() {
return title;
}

public boolean getVisible(){
return visible;
}

public void setVisible(boolean b){
visible = b;
}
}
Loading

0 comments on commit cf3489b

Please sign in to comment.