repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
|
final Preference prefUsername = findPreference(KEY_USERNAME);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@SuppressWarnings("deprecation")
@Override
public void onDisplayPreferenceDialog(Preference preference) {
if (preference instanceof EditTextPreference && KEY_HOST.equals(preference.getKey())) {
final UrlPreferenceDialogFragment fragment = UrlPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "UrlPreferenceDialogFragment");
} else if (preference instanceof AutoNamePreference && KEY_AUTO_NAME.equals(preference.getKey())) {
final AutoNamePreferenceDialogFragment fragment = AutoNamePreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "AutoNamePreferenceDialogFragment");
} else if (preference instanceof ListPreference && KEY_PROVIDER.equals(preference.getKey())) {
final ProviderPreferenceDialogFragment fragment = ProviderPreferenceDialogFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ProviderPreferenceDialogFragment");
} else if (preference instanceof ListPreference) {
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
|
final Preference prefPass = findPreference(KEY_PASS);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
final Preference prefPass = findPreference(KEY_PASS);
final Preference prefHost = findPreference(KEY_HOST);
// on change listeners
if (prefLiveSync != null) {
prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
}
if (prefUsername != null) {
prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefPass != null) {
prefPass.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefHost != null) {
prefHost.setOnPreferenceChangeListener(serverSetupChanged);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
final ListPreferenceDialogWithMessageFragment fragment = ListPreferenceDialogWithMessageFragment.newInstance(preference.getKey());
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
final Preference prefPass = findPreference(KEY_PASS);
final Preference prefHost = findPreference(KEY_HOST);
// on change listeners
if (prefLiveSync != null) {
prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
}
if (prefUsername != null) {
prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefPass != null) {
prefPass.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefHost != null) {
prefHost.setOnPreferenceChangeListener(serverSetupChanged);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
final Preference prefAutoStart = findPreference(KEY_AUTO_START);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
|
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
|
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
final Preference prefPass = findPreference(KEY_PASS);
final Preference prefHost = findPreference(KEY_HOST);
// on change listeners
if (prefLiveSync != null) {
prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
}
if (prefUsername != null) {
prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefPass != null) {
prefPass.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefHost != null) {
prefHost.setOnPreferenceChangeListener(serverSetupChanged);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
final Preference prefAutoStart = findPreference(KEY_AUTO_START);
|
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_ALLOW_EXTERNAL = "prefAllowExternal";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_NAME = "prefAutoName";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_AUTO_START = "prefAutoStart";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_HOST = "prefHost";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_LIVE_SYNC = "prefLiveSync";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PASS = "prefPass";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_PROVIDER = "prefProvider";
//
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsActivity.java
// public static final String KEY_USERNAME = "prefUsername";
// Path: app/src/main/java/net/fabiszewski/ulogger/SettingsFragment.java
import static androidx.activity.result.contract.ActivityResultContracts.RequestMultiplePermissions;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_ALLOW_EXTERNAL;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_NAME;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_AUTO_START;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_HOST;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_LIVE_SYNC;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PASS;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_PROVIDER;
import static net.fabiszewski.ulogger.SettingsActivity.KEY_USERNAME;
import android.Manifest;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat;
import androidx.preference.EditTextPreference;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceManager;
import androidx.preference.TwoStatePreference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;
import java.util.Map;
fragment.setTargetFragment(this, 0);
fragment.show(getParentFragmentManager(), "ListPreferenceDialogWithMessageFragment");
} else {
super.onDisplayPreferenceDialog(preference);
}
}
/**
* Set various listeners
*/
private void setListeners() {
final Preference prefLiveSync = findPreference(KEY_LIVE_SYNC);
final Preference prefUsername = findPreference(KEY_USERNAME);
final Preference prefPass = findPreference(KEY_PASS);
final Preference prefHost = findPreference(KEY_HOST);
// on change listeners
if (prefLiveSync != null) {
prefLiveSync.setOnPreferenceChangeListener(liveSyncChanged);
}
if (prefUsername != null) {
prefUsername.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefPass != null) {
prefPass.setOnPreferenceChangeListener(serverSetupChanged);
}
if (prefHost != null) {
prefHost.setOnPreferenceChangeListener(serverSetupChanged);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
final Preference prefAutoStart = findPreference(KEY_AUTO_START);
|
final Preference prefAllowExternal = findPreference(KEY_ALLOW_EXTERNAL);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/LoggerService.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_DISABLED = 2;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_PERMISSION = 1;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
// public final static String UPDATED_PREFS = "extra_updated_prefs";
|
import static net.fabiszewski.ulogger.LoggerTask.E_DISABLED;
import static net.fabiszewski.ulogger.LoggerTask.E_PERMISSION;
import static net.fabiszewski.ulogger.MainActivity.UPDATED_PREFS;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
|
thread = new HandlerThread("LoggerThread");
thread.start();
looper = thread.getLooper();
// keep database open during whole service runtime
db = DbAccess.getInstance();
db.open(this);
}
/**
* Request location updates, start web synchronization if needed
* @return True on success, false otherwise
*/
private boolean initializeLocationUpdates() {
if (Logger.DEBUG) { Log.d(TAG, "[initializeLocationUpdates]"); }
try {
locationHelper.updatePreferences();
locationHelper.requestLocationUpdates(locationListener, looper);
setRunning(true);
sendBroadcast(BROADCAST_LOCATION_STARTED);
syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
if (locationHelper.isLiveSync() && DbAccess.needsSync(this)) {
getApplicationContext().startService(syncIntent);
}
return true;
} catch (LocationHelper.LoggerException e) {
int errorCode = e.getCode();
|
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_DISABLED = 2;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_PERMISSION = 1;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
// public final static String UPDATED_PREFS = "extra_updated_prefs";
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerService.java
import static net.fabiszewski.ulogger.LoggerTask.E_DISABLED;
import static net.fabiszewski.ulogger.LoggerTask.E_PERMISSION;
import static net.fabiszewski.ulogger.MainActivity.UPDATED_PREFS;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
thread = new HandlerThread("LoggerThread");
thread.start();
looper = thread.getLooper();
// keep database open during whole service runtime
db = DbAccess.getInstance();
db.open(this);
}
/**
* Request location updates, start web synchronization if needed
* @return True on success, false otherwise
*/
private boolean initializeLocationUpdates() {
if (Logger.DEBUG) { Log.d(TAG, "[initializeLocationUpdates]"); }
try {
locationHelper.updatePreferences();
locationHelper.requestLocationUpdates(locationListener, looper);
setRunning(true);
sendBroadcast(BROADCAST_LOCATION_STARTED);
syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
if (locationHelper.isLiveSync() && DbAccess.needsSync(this)) {
getApplicationContext().startService(syncIntent);
}
return true;
} catch (LocationHelper.LoggerException e) {
int errorCode = e.getCode();
|
if (errorCode == E_DISABLED) {
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/LoggerService.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_DISABLED = 2;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_PERMISSION = 1;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
// public final static String UPDATED_PREFS = "extra_updated_prefs";
|
import static net.fabiszewski.ulogger.LoggerTask.E_DISABLED;
import static net.fabiszewski.ulogger.LoggerTask.E_PERMISSION;
import static net.fabiszewski.ulogger.MainActivity.UPDATED_PREFS;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
|
looper = thread.getLooper();
// keep database open during whole service runtime
db = DbAccess.getInstance();
db.open(this);
}
/**
* Request location updates, start web synchronization if needed
* @return True on success, false otherwise
*/
private boolean initializeLocationUpdates() {
if (Logger.DEBUG) { Log.d(TAG, "[initializeLocationUpdates]"); }
try {
locationHelper.updatePreferences();
locationHelper.requestLocationUpdates(locationListener, looper);
setRunning(true);
sendBroadcast(BROADCAST_LOCATION_STARTED);
syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
if (locationHelper.isLiveSync() && DbAccess.needsSync(this)) {
getApplicationContext().startService(syncIntent);
}
return true;
} catch (LocationHelper.LoggerException e) {
int errorCode = e.getCode();
if (errorCode == E_DISABLED) {
sendBroadcast(BROADCAST_LOCATION_DISABLED);
|
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_DISABLED = 2;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_PERMISSION = 1;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
// public final static String UPDATED_PREFS = "extra_updated_prefs";
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerService.java
import static net.fabiszewski.ulogger.LoggerTask.E_DISABLED;
import static net.fabiszewski.ulogger.LoggerTask.E_PERMISSION;
import static net.fabiszewski.ulogger.MainActivity.UPDATED_PREFS;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
looper = thread.getLooper();
// keep database open during whole service runtime
db = DbAccess.getInstance();
db.open(this);
}
/**
* Request location updates, start web synchronization if needed
* @return True on success, false otherwise
*/
private boolean initializeLocationUpdates() {
if (Logger.DEBUG) { Log.d(TAG, "[initializeLocationUpdates]"); }
try {
locationHelper.updatePreferences();
locationHelper.requestLocationUpdates(locationListener, looper);
setRunning(true);
sendBroadcast(BROADCAST_LOCATION_STARTED);
syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
if (locationHelper.isLiveSync() && DbAccess.needsSync(this)) {
getApplicationContext().startService(syncIntent);
}
return true;
} catch (LocationHelper.LoggerException e) {
int errorCode = e.getCode();
if (errorCode == E_DISABLED) {
sendBroadcast(BROADCAST_LOCATION_DISABLED);
|
} else if (errorCode == E_PERMISSION) {
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/LoggerService.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_DISABLED = 2;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_PERMISSION = 1;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
// public final static String UPDATED_PREFS = "extra_updated_prefs";
|
import static net.fabiszewski.ulogger.LoggerTask.E_DISABLED;
import static net.fabiszewski.ulogger.LoggerTask.E_PERMISSION;
import static net.fabiszewski.ulogger.MainActivity.UPDATED_PREFS;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
|
syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
if (locationHelper.isLiveSync() && DbAccess.needsSync(this)) {
getApplicationContext().startService(syncIntent);
}
return true;
} catch (LocationHelper.LoggerException e) {
int errorCode = e.getCode();
if (errorCode == E_DISABLED) {
sendBroadcast(BROADCAST_LOCATION_DISABLED);
} else if (errorCode == E_PERMISSION) {
sendBroadcast(BROADCAST_LOCATION_PERMISSION_DENIED);
}
}
return false;
}
/**
* Start foreground service
*
* @param intent Intent
* @param flags Flags
* @param startId Unique id
* @return Always returns START_STICKY
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (Logger.DEBUG) { Log.d(TAG, "[onStartCommand]"); }
|
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_DISABLED = 2;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerTask.java
// static final int E_PERMISSION = 1;
//
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
// public final static String UPDATED_PREFS = "extra_updated_prefs";
// Path: app/src/main/java/net/fabiszewski/ulogger/LoggerService.java
import static net.fabiszewski.ulogger.LoggerTask.E_DISABLED;
import static net.fabiszewski.ulogger.LoggerTask.E_PERMISSION;
import static net.fabiszewski.ulogger.MainActivity.UPDATED_PREFS;
import android.app.Notification;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager;
syncIntent = new Intent(getApplicationContext(), WebSyncService.class);
if (locationHelper.isLiveSync() && DbAccess.needsSync(this)) {
getApplicationContext().startService(syncIntent);
}
return true;
} catch (LocationHelper.LoggerException e) {
int errorCode = e.getCode();
if (errorCode == E_DISABLED) {
sendBroadcast(BROADCAST_LOCATION_DISABLED);
} else if (errorCode == E_PERMISSION) {
sendBroadcast(BROADCAST_LOCATION_PERMISSION_DENIED);
}
}
return false;
}
/**
* Start foreground service
*
* @param intent Intent
* @param flags Flags
* @param startId Unique id
* @return Always returns START_STICKY
*/
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (Logger.DEBUG) { Log.d(TAG, "[onStartCommand]"); }
|
if (intent != null && intent.getBooleanExtra(UPDATED_PREFS, false)) {
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";
|
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
|
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* Reread user preferences
*/
private void updatePreferences() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
preferenceUnits = prefs.getString(SettingsActivity.KEY_UNITS, getString(R.string.pref_units_default));
preferenceMinTimeMillis = Long.parseLong(prefs.getString(SettingsActivity.KEY_MIN_TIME, getString(R.string.pref_mintime_default))) * 1000;
preferenceLiveSync = prefs.getBoolean(SettingsActivity.KEY_LIVE_SYNC, false);
preferenceHost = prefs.getString(SettingsActivity.KEY_HOST, "").replaceAll("/+$", "");
}
/**
* Display warning if track name is not set
*/
public void showNoTrackWarning() {
showToast(getString(R.string.no_track_warning));
}
/**
* Start export service
*/
private void startExport() {
if (db.countPositions() > 0) {
try {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
/**
* Reread user preferences
*/
private void updatePreferences() {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
preferenceUnits = prefs.getString(SettingsActivity.KEY_UNITS, getString(R.string.pref_units_default));
preferenceMinTimeMillis = Long.parseLong(prefs.getString(SettingsActivity.KEY_MIN_TIME, getString(R.string.pref_mintime_default))) * 1000;
preferenceLiveSync = prefs.getBoolean(SettingsActivity.KEY_LIVE_SYNC, false);
preferenceHost = prefs.getString(SettingsActivity.KEY_HOST, "").replaceAll("/+$", "");
}
/**
* Display warning if track name is not set
*/
public void showNoTrackWarning() {
showToast(getString(R.string.no_track_warning));
}
/**
* Start export service
*/
private void startExport() {
if (db.countPositions() > 0) {
try {
|
getExportUri.launch(DbAccess.getTrackName(this) + GPX_EXTENSION);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";
|
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
|
/**
* Display warning if track name is not set
*/
public void showNoTrackWarning() {
showToast(getString(R.string.no_track_warning));
}
/**
* Start export service
*/
private void startExport() {
if (db.countPositions() > 0) {
try {
getExportUri.launch(DbAccess.getTrackName(this) + GPX_EXTENSION);
} catch (ActivityNotFoundException e) {
showToast(getString(R.string.cannot_open_picker), Toast.LENGTH_LONG);
}
} else {
showToast(getString(R.string.nothing_to_export));
}
}
private void clearTrack() {
if (LoggerService.isRunning()) {
showToast(getString(R.string.logger_running_warning));
return;
}
if (DbAccess.getTrackName(MainActivity.this) != null) {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
/**
* Display warning if track name is not set
*/
public void showNoTrackWarning() {
showToast(getString(R.string.no_track_warning));
}
/**
* Start export service
*/
private void startExport() {
if (db.countPositions() > 0) {
try {
getExportUri.launch(DbAccess.getTrackName(this) + GPX_EXTENSION);
} catch (ActivityNotFoundException e) {
showToast(getString(R.string.cannot_open_picker), Toast.LENGTH_LONG);
}
} else {
showToast(getString(R.string.nothing_to_export));
}
}
private void clearTrack() {
if (LoggerService.isRunning()) {
showToast(getString(R.string.logger_running_warning));
return;
}
if (DbAccess.getTrackName(MainActivity.this) != null) {
|
showConfirm(MainActivity.this,
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";
|
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
|
currentFragment.onResume();
}
}
);
}
}
/**
* Display toast message
* @param text Message
*/
private void showToast(CharSequence text) {
showToast(text, Toast.LENGTH_SHORT);
}
/**
* Display toast message
* @param text Message
* @param duration Duration
*/
private void showToast(CharSequence text, int duration) {
Context context = getApplicationContext();
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
/**
* Display About dialog
*/
private void showAbout() {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static AlertDialog showAlert(Activity context, CharSequence title, int layoutResource, int iconResource) {
// @SuppressLint("InflateParams")
// View view = context.getLayoutInflater().inflate(layoutResource, null, false);
// AlertDialog alertDialog = new AlertDialog.Builder(context).create();
// alertDialog.setTitle(title);
// alertDialog.setView(view);
// if (iconResource > 0) {
// alertDialog.setIcon(iconResource);
// }
// alertDialog.show();
// return alertDialog;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/Alert.java
// static void showConfirm(Context context, CharSequence title, CharSequence message,
// DialogInterface.OnClickListener yesCallback) {
// AlertDialog alertDialog = initDialog(context, title, message);
// alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, context.getString(R.string.ok), yesCallback);
// alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, context.getString(R.string.cancel),
// (dialog, which) -> dialog.dismiss());
// alertDialog.show();
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/GpxExportTask.java
// public static final String GPX_EXTENSION = ".gpx";
// Path: app/src/main/java/net/fabiszewski/ulogger/MainActivity.java
import static androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult;
import static net.fabiszewski.ulogger.Alert.showAlert;
import static net.fabiszewski.ulogger.Alert.showConfirm;
import static net.fabiszewski.ulogger.GpxExportTask.GPX_EXTENSION;
import static java.util.concurrent.Executors.newCachedThreadPool;
import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.core.text.HtmlCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.preference.PreferenceManager;
import java.util.concurrent.ExecutorService;
currentFragment.onResume();
}
}
);
}
}
/**
* Display toast message
* @param text Message
*/
private void showToast(CharSequence text) {
showToast(text, Toast.LENGTH_SHORT);
}
/**
* Display toast message
* @param text Message
* @param duration Duration
*/
private void showToast(CharSequence text, int duration) {
Context context = getApplicationContext();
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
/**
* Display About dialog
*/
private void showAbout() {
|
final AlertDialog dialog = showAlert(MainActivity.this,
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
|
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
|
uiHandler.post(() -> onPostExecute(result));
}
isRunning = false;
}
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
uiHandler.post(() -> onPostExecute(result));
}
isRunning = false;
}
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
|
getPersistablePermission(activity, uri);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
|
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
|
}
isRunning = false;
}
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
getPersistablePermission(activity, uri);
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
}
isRunning = false;
}
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
getPersistablePermission(activity, uri);
|
thumbnail = getThumbnail(activity, uri);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
|
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
|
}
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
getPersistablePermission(activity, uri);
thumbnail = getThumbnail(activity, uri);
} else {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
}
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
getPersistablePermission(activity, uri);
thumbnail = getThumbnail(activity, uri);
} else {
|
Bitmap bitmap = getResampledBitmap(activity, uri, dstWidth);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
|
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
|
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
getPersistablePermission(activity, uri);
thumbnail = getThumbnail(activity, uri);
} else {
Bitmap bitmap = getResampledBitmap(activity, uri, dstWidth);
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
public void cancel() {
if (Logger.DEBUG) { Log.d(TAG, "[task cancelled]"); }
isCancelled = true;
}
public boolean isRunning() {
return isRunning;
}
@WorkerThread
private ImageTaskResult doInBackground() {
if (Logger.DEBUG) { Log.d(TAG, "[doInBackground]"); }
Activity activity = getActivity();
if (activity == null) {
return null;
}
ImageTaskResult result = null;
try {
Uri savedUri;
Bitmap thumbnail;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity);
int dstWidth = Integer.parseInt(prefs.getString(SettingsActivity.KEY_IMAGE_SIZE, activity.getString(R.string.pref_imagesize_default)));
if (dstWidth == 0) {
savedUri = uri;
getPersistablePermission(activity, uri);
thumbnail = getThumbnail(activity, uri);
} else {
Bitmap bitmap = getResampledBitmap(activity, uri, dstWidth);
|
savedUri = saveToCache(activity, bitmap);
|
bfabiszewski/ulogger-android
|
app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
|
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
|
}
@UiThread
private void onPostExecute(@Nullable ImageTaskResult result) {
ImageTaskCallback callback = weakCallback.get();
if (callback != null && callback.getActivity() != null) {
if (result == null) {
callback.onImageTaskFailure(errorMessage);
} else {
callback.onImageTaskCompleted(result.savedUri, result.thumbnail);
}
}
}
@Nullable
private Activity getActivity() {
ImageTaskCallback callback = weakCallback.get();
if (callback != null) {
return callback.getActivity();
}
return null;
}
/**
* Try to clean image cache
* @param result Task result
*/
private void cleanUp(ImageTaskResult result) {
Activity activity = getActivity();
if (result != null && activity != null) {
|
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void clearImageCache(@NonNull Context context) {
// File dir = context.getCacheDir();
// clearImages(dir);
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static void getPersistablePermission(@NonNull Context context, @NonNull Uri uri) {
// try {
// context.getContentResolver().takePersistableUriPermission(uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
// } catch (SecurityException e) {
// if (Logger.DEBUG) { Log.d(TAG, "[getPersistablePermission failed for " + uri + "]"); }
// }
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getResampledBitmap(@NonNull Context context, @NonNull Uri uri, int dstWidth) throws IOException {
// ContentResolver cr = context.getContentResolver();
// BitmapFactory.Options options = new BitmapFactory.Options();
// options.inJustDecodeBounds = true;
// try (InputStream is = cr.openInputStream(uri)) {
// BitmapFactory.decodeStream(is, null, options);
// }
// int srcWidth = Math.max(options.outWidth, options.outHeight);
// int scale = srcWidth / dstWidth;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded scale: " + scale + "]"); }
// options = new BitmapFactory.Options();
// Bitmap bitmap = null;
// boolean retry = false;
// do {
// try {
// if (scale > 1) {
// options.inScaled = true;
// options.inSampleSize = 1;
// options.inDensity = srcWidth;
// options.inTargetDensity = dstWidth * options.inSampleSize;
// }
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, options);
// }
// } catch (OutOfMemoryError e) {
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded OutOfMemoryError]"); }
// if (retry) {
// throw new IOException("Out of memory");
// } else if (scale > 1) {
// retry = true;
// options.inSampleSize = scale;
// if (Logger.DEBUG) { Log.d(TAG, "[resampleIfNeeded try sampling]"); }
// }
// }
// } while (retry);
//
// if (bitmap == null) {
// throw new IOException("Failed to decode image");
// }
//
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Bitmap getThumbnail(@NonNull Context context, @NonNull Uri uri) throws IOException {
// int sizePx = getThumbnailSize(context);
// Bitmap bitmap;
// ContentResolver cr = context.getContentResolver();
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
// bitmap = cr.loadThumbnail(uri, new Size(sizePx, sizePx), null);
// } else {
// try (InputStream is = cr.openInputStream(uri)) {
// bitmap = BitmapFactory.decodeStream(is, null, null);
// }
//
// bitmap = ThumbnailUtils.extractThumbnail(bitmap, sizePx, sizePx);
// }
// bitmap = fixImageOrientation(context, uri, bitmap);
// return bitmap;
// }
//
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageHelper.java
// static Uri saveToCache(@NonNull Context context, @NonNull Bitmap bitmap) throws IOException {
// String filename = getUniqueName() + EXT_JPG;
// File outFile = new File(context.getCacheDir(), filename);
// try (FileOutputStream os = new FileOutputStream(outFile)) {
// bitmap.compress(Bitmap.CompressFormat.JPEG, 90, os);
// }
// return Uri.fromFile(outFile);
// }
// Path: app/src/main/java/net/fabiszewski/ulogger/ImageTask.java
import android.app.Activity;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
import androidx.annotation.WorkerThread;
import androidx.preference.PreferenceManager;
import java.io.IOException;
import java.lang.ref.WeakReference;
import static net.fabiszewski.ulogger.ImageHelper.clearImageCache;
import static net.fabiszewski.ulogger.ImageHelper.getPersistablePermission;
import static net.fabiszewski.ulogger.ImageHelper.getResampledBitmap;
import static net.fabiszewski.ulogger.ImageHelper.getThumbnail;
import static net.fabiszewski.ulogger.ImageHelper.saveToCache;
}
@UiThread
private void onPostExecute(@Nullable ImageTaskResult result) {
ImageTaskCallback callback = weakCallback.get();
if (callback != null && callback.getActivity() != null) {
if (result == null) {
callback.onImageTaskFailure(errorMessage);
} else {
callback.onImageTaskCompleted(result.savedUri, result.thumbnail);
}
}
}
@Nullable
private Activity getActivity() {
ImageTaskCallback callback = weakCallback.get();
if (callback != null) {
return callback.getActivity();
}
return null;
}
/**
* Try to clean image cache
* @param result Task result
*/
private void cleanUp(ImageTaskResult result) {
Activity activity = getActivity();
if (result != null && activity != null) {
|
clearImageCache(activity.getApplicationContext());
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/TestRepositoryService.java
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
|
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.google.inject.Singleton;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
@Singleton
public class TestRepositoryService
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
// Path: centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/TestRepositoryService.java
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.google.inject.Singleton;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
@Singleton
public class TestRepositoryService
|
implements RepositoryService
|
brettporter/centrepoint
|
plugins/continuum-builds-plugin/src/main/java/com/effectivemaven/centrepoint/plugins/continuum/ContinuumBuildsPlugin.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
|
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import org.apache.maven.continuum.xmlrpc.client.ContinuumXmlRpcClient;
import org.apache.maven.continuum.xmlrpc.project.BuildResultSummary;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
|
package com.effectivemaven.centrepoint.plugins.continuum;
public class ContinuumBuildsPlugin
implements PanelPlugin, ConfigurablePanel<ContinuumModel>
{
private static Logger logger = Logger.getLogger( ContinuumBuildsPlugin.class.getName() );
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
// Path: plugins/continuum-builds-plugin/src/main/java/com/effectivemaven/centrepoint/plugins/continuum/ContinuumBuildsPlugin.java
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import org.apache.maven.continuum.xmlrpc.client.ContinuumXmlRpcClient;
import org.apache.maven.continuum.xmlrpc.project.BuildResultSummary;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
package com.effectivemaven.centrepoint.plugins.continuum;
public class ContinuumBuildsPlugin
implements PanelPlugin, ConfigurablePanel<ContinuumModel>
{
private static Logger logger = Logger.getLogger( ContinuumBuildsPlugin.class.getName() );
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
public List<PanelItem> getItems( Project project )
|
brettporter/centrepoint
|
plugin-skeleton/src/test/java/com/effectivemaven/centrepoint/plugins/MyPluginTest.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
|
import java.util.List;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
|
plugin = new MyPlugin();
project = new Project();
}
@Test
public void testTitle()
{
assert "Links".equals( plugin.getTitle( null ) );
assert "Links".equals( plugin.getTitle( project ) );
}
@Test
public void testGetId()
{
assert "my-plugin".equals( plugin.getId() );
}
@Test
public void testGetModel()
{
assert project.getExtensionModel( "my-plugin" ) == null;
MyModel model = plugin.getModel( project );
assert model == project.getExtensionModel( "my-plugin" );
assert model == plugin.getModel( project );
}
@Test
public void testGetItemsEmpty()
{
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
// Path: plugin-skeleton/src/test/java/com/effectivemaven/centrepoint/plugins/MyPluginTest.java
import java.util.List;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
plugin = new MyPlugin();
project = new Project();
}
@Test
public void testTitle()
{
assert "Links".equals( plugin.getTitle( null ) );
assert "Links".equals( plugin.getTitle( project ) );
}
@Test
public void testGetId()
{
assert "my-plugin".equals( plugin.getId() );
}
@Test
public void testGetModel()
{
assert project.getExtensionModel( "my-plugin" ) == null;
MyModel model = plugin.getModel( project );
assert model == project.getExtensionModel( "my-plugin" );
assert model == plugin.getModel( project );
}
@Test
public void testGetItemsEmpty()
{
|
List<PanelItem> items = plugin.getItems( project );
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/ViewProjectPage.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.protocol.http.servlet.AbortWithHttpStatusException;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
/**
* Web page to display information and other panels about a given project.
*/
public class ViewProjectPage
extends TemplatePage
{
@Inject
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/ViewProjectPage.java
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.protocol.http.servlet.AbortWithHttpStatusException;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
/**
* Web page to display information and other panels about a given project.
*/
public class ViewProjectPage
extends TemplatePage
{
@Inject
|
private ProjectStore projectStore;
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/ViewProjectPage.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.protocol.http.servlet.AbortWithHttpStatusException;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
/**
* Web page to display information and other panels about a given project.
*/
public class ViewProjectPage
extends TemplatePage
{
@Inject
private ProjectStore projectStore;
@Inject
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/ViewProjectPage.java
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.protocol.http.servlet.AbortWithHttpStatusException;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
/**
* Web page to display information and other panels about a given project.
*/
public class ViewProjectPage
extends TemplatePage
{
@Inject
private ProjectStore projectStore;
@Inject
|
private PluginManager pluginManager;
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/ViewProjectPage.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.protocol.http.servlet.AbortWithHttpStatusException;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
|
}
final String id = parameters.getString( "id" );
Project project = projectStore.getProjectById( id );
if ( project == null )
{
throw new AbortWithHttpStatusException( 404, true );
}
setPageTitle( project.getName() );
add( new Label( "name", project.getName() ) );
add( new MultiLineLabel( "description", project.getDescription() ) );
add( new Label( "version", project.getVersion() ) );
add( new HideableExternalLink( "url", project.getUrl() ) );
add( new HideableExternalLink( "scmUrl", project.getScmUrl() ) );
add( new HideableExternalLink( "issueTrackerUrl", project.getIssueTrackerUrl() ) );
MavenCoordinates coordinates = (MavenCoordinates) project.getExtensionModel( "maven" );
if ( coordinates == null )
{
coordinates = new MavenCoordinates();
}
add( new Label( "maven|groupId", coordinates.getGroupId() ) );
add( new Label( "maven|artifactId", coordinates.getArtifactId() ) );
for ( PanelPlugin panel : pluginManager.getPlugins() )
{
List<AbstractLink> links = new ArrayList<AbstractLink>();
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/ViewProjectPage.java
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
import java.util.ArrayList;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.basic.MultiLineLabel;
import org.apache.wicket.markup.html.link.AbstractLink;
import org.apache.wicket.protocol.http.servlet.AbortWithHttpStatusException;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
}
final String id = parameters.getString( "id" );
Project project = projectStore.getProjectById( id );
if ( project == null )
{
throw new AbortWithHttpStatusException( 404, true );
}
setPageTitle( project.getName() );
add( new Label( "name", project.getName() ) );
add( new MultiLineLabel( "description", project.getDescription() ) );
add( new Label( "version", project.getVersion() ) );
add( new HideableExternalLink( "url", project.getUrl() ) );
add( new HideableExternalLink( "scmUrl", project.getScmUrl() ) );
add( new HideableExternalLink( "issueTrackerUrl", project.getIssueTrackerUrl() ) );
MavenCoordinates coordinates = (MavenCoordinates) project.getExtensionModel( "maven" );
if ( coordinates == null )
{
coordinates = new MavenCoordinates();
}
add( new Label( "maven|groupId", coordinates.getGroupId() ) );
add( new Label( "maven|artifactId", coordinates.getArtifactId() ) );
for ( PanelPlugin panel : pluginManager.getPlugins() )
{
List<AbstractLink> links = new ArrayList<AbstractLink>();
|
for ( PanelItem item : panel.getItems( project ) )
|
brettporter/centrepoint
|
plugin-skeleton/src/main/java/com/effectivemaven/centrepoint/plugins/MyPlugin.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
|
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import java.util.Arrays;
import java.util.List;
|
package com.effectivemaven.centrepoint.plugins;
public class MyPlugin
implements PanelPlugin, ConfigurablePanel<MyModel>
{
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
// Path: plugin-skeleton/src/main/java/com/effectivemaven/centrepoint/plugins/MyPlugin.java
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import java.util.Arrays;
import java.util.List;
package com.effectivemaven.centrepoint.plugins;
public class MyPlugin
implements PanelPlugin, ConfigurablePanel<MyModel>
{
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
public List<PanelItem> getItems( Project project )
|
brettporter/centrepoint
|
centrepoint/plugin-archetype/src/main/resources/archetype-resources/src/main/java/MyPlugin.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
|
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import java.util.Arrays;
import java.util.List;
|
#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package};
public class MyPlugin
implements PanelPlugin, ConfigurablePanel<MyModel>
{
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
// Path: centrepoint/plugin-archetype/src/main/resources/archetype-resources/src/main/java/MyPlugin.java
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
import java.util.Arrays;
import java.util.List;
#set( $symbol_pound = '#' )
#set( $symbol_dollar = '$' )
#set( $symbol_escape = '\' )
package ${package};
public class MyPlugin
implements PanelPlugin, ConfigurablePanel<MyModel>
{
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
public List<PanelItem> getItems( Project project )
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/AddProjectFromMavenPage.java
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
|
import java.io.Serializable;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.Model;
import com.effectivemaven.centrepoint.maven.MavenProjectImporter;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.google.inject.Inject;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
/**
* Page for importing a project into Centrepoint from Maven. The user is prompted for the group ID and artifact ID, and
* a version is selected from a Maven repository. The POM is then imported and stored via the importer service.
*/
public class AddProjectFromMavenPage
extends TemplatePage
{
/**
* Constructor.
*/
public AddProjectFromMavenPage()
{
super();
setPageTitle( "Add Project" );
add( new FeedbackPanel( "feedback" ) );
add( new InputForm( "addMavenProjectForm" ) );
}
@SuppressWarnings("serial")
private static class InputFormModel
implements Serializable
{
String groupId;
String artifactId;
}
@SuppressWarnings("serial")
private static class InputForm
extends Form<InputFormModel>
{
/** Maven repository service for querying. */
@Inject
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
// Path: centrepoint/modules/webapp/src/main/java/com/effectivemaven/centrepoint/web/AddProjectFromMavenPage.java
import java.io.Serializable;
import java.util.List;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.Model;
import com.effectivemaven.centrepoint.maven.MavenProjectImporter;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.google.inject.Inject;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
/**
* Page for importing a project into Centrepoint from Maven. The user is prompted for the group ID and artifact ID, and
* a version is selected from a Maven repository. The POM is then imported and stored via the importer service.
*/
public class AddProjectFromMavenPage
extends TemplatePage
{
/**
* Constructor.
*/
public AddProjectFromMavenPage()
{
super();
setPageTitle( "Add Project" );
add( new FeedbackPanel( "feedback" ) );
add( new InputForm( "addMavenProjectForm" ) );
}
@SuppressWarnings("serial")
private static class InputFormModel
implements Serializable
{
String groupId;
String artifactId;
}
@SuppressWarnings("serial")
private static class InputForm
extends Form<InputFormModel>
{
/** Maven repository service for querying. */
@Inject
|
private RepositoryService repositoryService;
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/AbstractPageWithStoreTest.java
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import java.net.URL;
import java.net.URLClassLoader;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.effectivemaven.centrepoint.store.ProjectStore;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
public abstract class AbstractPageWithStoreTest
{
static class PageWithStoreModule
extends AbstractModule
{
@Override
protected void configure()
{
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/AbstractPageWithStoreTest.java
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import java.net.URL;
import java.net.URLClassLoader;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.effectivemaven.centrepoint.store.ProjectStore;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
public abstract class AbstractPageWithStoreTest
{
static class PageWithStoreModule
extends AbstractModule
{
@Override
protected void configure()
{
|
bind( ProjectStore.class ).to( MemoryProjectStore.class );
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/AbstractPageWithStoreTest.java
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import java.net.URL;
import java.net.URLClassLoader;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.effectivemaven.centrepoint.store.ProjectStore;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
public abstract class AbstractPageWithStoreTest
{
static class PageWithStoreModule
extends AbstractModule
{
@Override
protected void configure()
{
bind( ProjectStore.class ).to( MemoryProjectStore.class );
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/AbstractPageWithStoreTest.java
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import java.net.URL;
import java.net.URLClassLoader;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.effectivemaven.centrepoint.store.ProjectStore;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
public abstract class AbstractPageWithStoreTest
{
static class PageWithStoreModule
extends AbstractModule
{
@Override
protected void configure()
{
bind( ProjectStore.class ).to( MemoryProjectStore.class );
|
bind( RepositoryService.class ).to( TestRepositoryService.class );
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/AbstractPageWithStoreTest.java
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import java.net.URL;
import java.net.URLClassLoader;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.effectivemaven.centrepoint.store.ProjectStore;
|
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
public abstract class AbstractPageWithStoreTest
{
static class PageWithStoreModule
extends AbstractModule
{
@Override
protected void configure()
{
bind( ProjectStore.class ).to( MemoryProjectStore.class );
bind( RepositoryService.class ).to( TestRepositoryService.class );
|
// Path: centrepoint/modules/maven-importer/src/main/java/com/effectivemaven/centrepoint/maven/repository/RepositoryService.java
// @ImplementedBy( CentralRepositoryService.class )
// public interface RepositoryService
// {
// /**
// * Get the available versions for a given artifact by querying the repository metadata.
// * The versions should be returned in sorted order from oldest to newest.
// *
// * @param groupId the group ID of the artifact to query
// * @param artifactId the artifact ID of the artifact to query
// * @return versions available in the repository
// * @throws RepositoryException
// */
// List<String> getAvailableVersions( String groupId, String artifactId )
// throws RepositoryException;
//
// /**
// * Retrieve a project from the repository and convert it to a basic Centrepoint project model.
// *
// * @param groupId the Maven group ID to lookup
// * @param artifactId the Maven artifact ID to lookup
// * @param version the Maven artifact version to lookup
// * @return the project created
// * @throws RepositoryException
// */
// Project retrieveProject( String groupId, String artifactId, String version )
// throws RepositoryException;
// }
//
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/AbstractPageWithStoreTest.java
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.Scopes;
import com.google.inject.name.Names;
import java.net.URL;
import java.net.URLClassLoader;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.util.tester.WicketTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import com.effectivemaven.centrepoint.maven.repository.RepositoryService;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.effectivemaven.centrepoint.store.ProjectStore;
package com.effectivemaven.centrepoint.web;
/**
* Copyright 2009
*
* 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.
*/
public abstract class AbstractPageWithStoreTest
{
static class PageWithStoreModule
extends AbstractModule
{
@Override
protected void configure()
{
bind( ProjectStore.class ).to( MemoryProjectStore.class );
bind( RepositoryService.class ).to( TestRepositoryService.class );
|
bind( PluginManager.class ).to( PluginManagerImpl.class ).in( Scopes.SINGLETON );
|
brettporter/centrepoint
|
plugins/archiva-search-plugin/src/main/java/com/effectivemaven/centrepoint/plugins/archiva/ArchivaSearchPlugin.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
|
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import org.apache.archiva.web.xmlrpc.api.SearchService;
import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
import com.atlassian.xmlrpc.Binder;
import com.atlassian.xmlrpc.BindingException;
import com.atlassian.xmlrpc.ConnectionInfo;
import com.atlassian.xmlrpc.DefaultBinder;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
|
package com.effectivemaven.centrepoint.plugins.archiva;
public class ArchivaSearchPlugin
implements PanelPlugin
{
private static Logger logger = Logger.getLogger( ArchivaSearchPlugin.class.getName() );
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
// Path: plugins/archiva-search-plugin/src/main/java/com/effectivemaven/centrepoint/plugins/archiva/ArchivaSearchPlugin.java
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.logging.Logger;
import org.apache.archiva.web.xmlrpc.api.SearchService;
import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
import com.atlassian.xmlrpc.Binder;
import com.atlassian.xmlrpc.BindingException;
import com.atlassian.xmlrpc.ConnectionInfo;
import com.atlassian.xmlrpc.DefaultBinder;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
import com.effectivemaven.centrepoint.model.plugin.PanelPlugin;
package com.effectivemaven.centrepoint.plugins.archiva;
public class ArchivaSearchPlugin
implements PanelPlugin
{
private static Logger logger = Logger.getLogger( ArchivaSearchPlugin.class.getName() );
/**
* Get a list of items present in the panel.
*
* @return the list of panel items
*/
|
public List<PanelItem> getItems( Project project )
|
brettporter/centrepoint
|
centrepoint/plugin-archetype/src/main/resources/archetype-resources/src/test/java/MyPluginTest.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
|
import java.util.List;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
|
plugin = new MyPlugin();
project = new Project();
}
@Test
public void testTitle()
{
assert "Links".equals( plugin.getTitle( null ) );
assert "Links".equals( plugin.getTitle( project ) );
}
@Test
public void testGetId()
{
assert "my-plugin".equals( plugin.getId() );
}
@Test
public void testGetModel()
{
assert project.getExtensionModel( "my-plugin" ) == null;
MyModel model = plugin.getModel( project );
assert model == project.getExtensionModel( "my-plugin" );
assert model == plugin.getModel( project );
}
@Test
public void testGetItemsEmpty()
{
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PanelItem.java
// public class PanelItem
// {
// /** The label to display for the text or link. */
// private final String name;
//
// /** The optional URL to link to. */
// private final String url;
//
// public PanelItem( String name )
// {
// this.name = name;
// this.url = null;
// }
//
// public PanelItem( String name, String url )
// {
// this.name = name;
// this.url = url;
// }
//
// public String getName()
// {
// return name;
// }
//
// public String getUrl()
// {
// return url;
// }
// }
// Path: centrepoint/plugin-archetype/src/main/resources/archetype-resources/src/test/java/MyPluginTest.java
import java.util.List;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PanelItem;
plugin = new MyPlugin();
project = new Project();
}
@Test
public void testTitle()
{
assert "Links".equals( plugin.getTitle( null ) );
assert "Links".equals( plugin.getTitle( project ) );
}
@Test
public void testGetId()
{
assert "my-plugin".equals( plugin.getId() );
}
@Test
public void testGetModel()
{
assert project.getExtensionModel( "my-plugin" ) == null;
MyModel model = plugin.getModel( project );
assert model == project.getExtensionModel( "my-plugin" );
assert model == plugin.getModel( project );
}
@Test
public void testGetItemsEmpty()
{
|
List<PanelItem> items = plugin.getItems( project );
|
brettporter/centrepoint
|
centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/EditPanelConfigurationPageTest.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
|
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.util.tester.FormTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.effectivemaven.centrepoint.model.ExtensionModel;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.google.inject.Guice;
import com.google.inject.Module;
import com.google.inject.name.Names;
|
{
PageParameters params = new PageParameters();
params.add( "id", "idValue" );
params.add( "panel", "badValue" );
wicketTester.startPage( EditPanelConfigurationPage.class, params );
assert 404 == wicketTester.getServletResponse().getStatus();
}
@Test
public void testCreateSettings()
{
PageParameters params = createParams( "idValue", "my-plugin" );
wicketTester.startPage( EditPanelConfigurationPage.class, params );
FormTester formTester = wicketTester.newFormTester( EDIT_PANEL_CONFIG_FORM );
formTester.setValue( "row:1:value", "http://www.effectivemaven.com/" );
formTester.submit();
wicketTester.assertRenderedPage( ViewProjectPage.class );
wicketTester.assertNoErrorMessage();
Project project = projectStore.getProjectById( "idValue" );
ExtensionModel model = project.getExtensionModel( "my-plugin" );
assert model != null;
assert "http://www.effectivemaven.com/".equals( model.getValuesAsMap().get( "link" ) );
}
@Test
public void testPrePopulateAndUpdate()
{
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
// Path: centrepoint/modules/webapp/src/test/java/com/effectivemaven/centrepoint/web/EditPanelConfigurationPageTest.java
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.FeedbackPanel;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.util.tester.FormTester;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.effectivemaven.centrepoint.model.ExtensionModel;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.MemoryProjectStore;
import com.google.inject.Guice;
import com.google.inject.Module;
import com.google.inject.name.Names;
{
PageParameters params = new PageParameters();
params.add( "id", "idValue" );
params.add( "panel", "badValue" );
wicketTester.startPage( EditPanelConfigurationPage.class, params );
assert 404 == wicketTester.getServletResponse().getStatus();
}
@Test
public void testCreateSettings()
{
PageParameters params = createParams( "idValue", "my-plugin" );
wicketTester.startPage( EditPanelConfigurationPage.class, params );
FormTester formTester = wicketTester.newFormTester( EDIT_PANEL_CONFIG_FORM );
formTester.setValue( "row:1:value", "http://www.effectivemaven.com/" );
formTester.submit();
wicketTester.assertRenderedPage( ViewProjectPage.class );
wicketTester.assertNoErrorMessage();
Project project = projectStore.getProjectById( "idValue" );
ExtensionModel model = project.getExtensionModel( "my-plugin" );
assert model != null;
assert "http://www.effectivemaven.com/".equals( model.getValuesAsMap().get( "link" ) );
}
@Test
public void testPrePopulateAndUpdate()
{
|
PluginManager manager = injector.getInstance( PluginManager.class );
|
brettporter/centrepoint
|
centrepoint/modules/store-file/src/main/java/com/effectivemaven/centrepoint/store/properties/PropertiesProjectStore.java
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
|
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
import com.effectivemaven.centrepoint.model.ExtensionModel;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
|
package com.effectivemaven.centrepoint.store.properties;
/**
* Copyright 2009
*
* 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.
*/
public class PropertiesProjectStore
implements ProjectStore
{
/** The projects, cached in memory. */
private Map<String, Project> projects = new LinkedHashMap<String, Project>();
/** Where to save the projects on disk. */
private String dataLocation;
/** Logger. */
private static Logger logger = Logger.getLogger( PropertiesProjectStore.class.getName() );
/**
* Configuration parameters that can be modified by alternate bindings in Guice.
*/
static class RepositoryParams
{
@Inject( optional = true )
private @DataLocation
String dataLocation = System.getProperty( "user.home" ) + "/.centrepoint/";
}
@Inject
|
// Path: centrepoint/modules/model/src/main/java/com/effectivemaven/centrepoint/model/plugin/PluginManager.java
// public interface PluginManager
// {
// /**
// * Retrieve all plugins available (whether they are configurable or not).
// *
// * @return the list of plugins
// */
// Collection<PanelPlugin> getPlugins();
//
// /**
// * Retrieve all plugins available that take configuration options.
// *
// * @return the list of configurable plugins
// */
// Collection<ConfigurablePanel<? extends ExtensionModel>> getConfigurablePlugins();
//
// /**
// * Retrieve a specific configurable plugin, based on the ID of the configuration model.
// *
// * @param id the ID of the plugin's configuration model, which should match the value of
// * {@link ConfigurablePanel#getId()}
// * @return the plugin, or <tt>null</tt> if not found
// */
// ConfigurablePanel<? extends ExtensionModel> getConfigurablePlugin( String id );
// }
//
// Path: centrepoint/modules/store-api/src/main/java/com/effectivemaven/centrepoint/store/ProjectStore.java
// public interface ProjectStore
// {
// /**
// * Retrieve all projects in their entirety.
// * @return the project list
// */
// Collection<Project> getAllProjects();
//
// /**
// * Retrieve a specific project.
// * @param id the identifier of the project to retrieve
// * @return the project, or <code>null</code> if not found
// */
// Project getProjectById( String id );
//
// /**
// * Store the project.
// * @param project the project to store
// */
// void store( Project project );
// }
// Path: centrepoint/modules/store-file/src/main/java/com/effectivemaven/centrepoint/store/properties/PropertiesProjectStore.java
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
import com.effectivemaven.centrepoint.model.ExtensionModel;
import com.effectivemaven.centrepoint.model.MavenCoordinates;
import com.effectivemaven.centrepoint.model.Project;
import com.effectivemaven.centrepoint.model.plugin.ConfigurablePanel;
import com.effectivemaven.centrepoint.model.plugin.PluginManager;
import com.effectivemaven.centrepoint.store.ProjectStore;
import com.google.inject.Inject;
package com.effectivemaven.centrepoint.store.properties;
/**
* Copyright 2009
*
* 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.
*/
public class PropertiesProjectStore
implements ProjectStore
{
/** The projects, cached in memory. */
private Map<String, Project> projects = new LinkedHashMap<String, Project>();
/** Where to save the projects on disk. */
private String dataLocation;
/** Logger. */
private static Logger logger = Logger.getLogger( PropertiesProjectStore.class.getName() );
/**
* Configuration parameters that can be modified by alternate bindings in Guice.
*/
static class RepositoryParams
{
@Inject( optional = true )
private @DataLocation
String dataLocation = System.getProperty( "user.home" ) + "/.centrepoint/";
}
@Inject
|
private PropertiesProjectStore( RepositoryParams params, PluginManager pluginManager )
|
gwtproject/gwt-event
|
src/main/java/org/gwtproject/event/shared/EventBus.java
|
// Path: src/main/java/org/gwtproject/event/shared/Event.java
// public static class Type<H> {
// private static int nextHashCode;
// private final int index;
//
// /** Constructor. */
// public Type() {
// index = ++nextHashCode;
// }
//
// @Override
// public final int hashCode() {
// return index;
// }
//
// @Override
// public String toString() {
// return "Event type";
// }
// }
|
import org.gwtproject.event.shared.Event.Type;
|
/*
* Copyright 2011 The GWT Project Authors
*
* 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 org.gwtproject.event.shared;
/**
* Dispatches {@link Event}s to interested parties. Eases decoupling by allowing objects to interact
* without having direct dependencies upon one another, and without requiring event sources to deal
* with maintaining handler lists. There will typically be one EventBus per application,
* broadcasting events that may be of general interest.
*
* @see SimpleEventBus
* @see ResettableEventBus
* @see org.gwtproject.event.shared.testing.CountingEventBus
*/
public abstract class EventBus implements HasHandlers {
/**
* Invokes {@code event.dispatch} with {@code handler}.
*
* <p>Protected to allow EventBus implementations in different packages to dispatch events even
* though the {@code event.dispatch} method is protected.
*/
protected static <H> void dispatchEvent(Event<H> event, H handler) {
event.dispatch(handler);
}
/**
* Sets {@code source} as the source of {@code event}.
*
* <p>Protected to allow EventBus implementations in different packages to set an event source
* even though the {@code event.setSource} method is protected.
*/
protected static void setSourceOfEvent(Event<?> event, Object source) {
event.setSource(source);
}
/**
* Adds an unfiltered handler to receive events of this type from all sources.
*
* <p>It is rare to call this method directly. More typically an {@link Event} subclass will
* provide a static <code>register</code> method, or a widget will accept handlers directly.
*
* @param <H> The type of handler
* @param type the event type associated with this handler
* @param handler the handler
* @return the handler registration, can be stored in order to remove the handler later
*/
|
// Path: src/main/java/org/gwtproject/event/shared/Event.java
// public static class Type<H> {
// private static int nextHashCode;
// private final int index;
//
// /** Constructor. */
// public Type() {
// index = ++nextHashCode;
// }
//
// @Override
// public final int hashCode() {
// return index;
// }
//
// @Override
// public String toString() {
// return "Event type";
// }
// }
// Path: src/main/java/org/gwtproject/event/shared/EventBus.java
import org.gwtproject.event.shared.Event.Type;
/*
* Copyright 2011 The GWT Project Authors
*
* 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 org.gwtproject.event.shared;
/**
* Dispatches {@link Event}s to interested parties. Eases decoupling by allowing objects to interact
* without having direct dependencies upon one another, and without requiring event sources to deal
* with maintaining handler lists. There will typically be one EventBus per application,
* broadcasting events that may be of general interest.
*
* @see SimpleEventBus
* @see ResettableEventBus
* @see org.gwtproject.event.shared.testing.CountingEventBus
*/
public abstract class EventBus implements HasHandlers {
/**
* Invokes {@code event.dispatch} with {@code handler}.
*
* <p>Protected to allow EventBus implementations in different packages to dispatch events even
* though the {@code event.dispatch} method is protected.
*/
protected static <H> void dispatchEvent(Event<H> event, H handler) {
event.dispatch(handler);
}
/**
* Sets {@code source} as the source of {@code event}.
*
* <p>Protected to allow EventBus implementations in different packages to set an event source
* even though the {@code event.setSource} method is protected.
*/
protected static void setSourceOfEvent(Event<?> event, Object source) {
event.setSource(source);
}
/**
* Adds an unfiltered handler to receive events of this type from all sources.
*
* <p>It is rare to call this method directly. More typically an {@link Event} subclass will
* provide a static <code>register</code> method, or a widget will accept handlers directly.
*
* @param <H> The type of handler
* @param type the event type associated with this handler
* @param handler the handler
* @return the handler registration, can be stored in order to remove the handler later
*/
|
public abstract <H> HandlerRegistration addHandler(Type<H> type, H handler);
|
gwtproject/gwt-event
|
src/main/java/org/gwtproject/event/shared/ResettableEventBus.java
|
// Path: src/main/java/org/gwtproject/event/shared/Event.java
// public static class Type<H> {
// private static int nextHashCode;
// private final int index;
//
// /** Constructor. */
// public Type() {
// index = ++nextHashCode;
// }
//
// @Override
// public final int hashCode() {
// return index;
// }
//
// @Override
// public String toString() {
// return "Event type";
// }
// }
|
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.gwtproject.event.shared.Event.Type;
|
/*
* Copyright 2011 The GWT Project Authors
*
* 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 org.gwtproject.event.shared;
/**
* Wraps an EventBus to hold on to any HandlerRegistrations, so that they can easily all be cleared
* at once.
*/
public class ResettableEventBus extends EventBus {
private final EventBus wrapped;
private final Set<HandlerRegistration> registrations = new HashSet<>();
public ResettableEventBus(EventBus wrappedBus) {
this.wrapped = wrappedBus;
}
@Override
|
// Path: src/main/java/org/gwtproject/event/shared/Event.java
// public static class Type<H> {
// private static int nextHashCode;
// private final int index;
//
// /** Constructor. */
// public Type() {
// index = ++nextHashCode;
// }
//
// @Override
// public final int hashCode() {
// return index;
// }
//
// @Override
// public String toString() {
// return "Event type";
// }
// }
// Path: src/main/java/org/gwtproject/event/shared/ResettableEventBus.java
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import org.gwtproject.event.shared.Event.Type;
/*
* Copyright 2011 The GWT Project Authors
*
* 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 org.gwtproject.event.shared;
/**
* Wraps an EventBus to hold on to any HandlerRegistrations, so that they can easily all be cleared
* at once.
*/
public class ResettableEventBus extends EventBus {
private final EventBus wrapped;
private final Set<HandlerRegistration> registrations = new HashSet<>();
public ResettableEventBus(EventBus wrappedBus) {
this.wrapped = wrappedBus;
}
@Override
|
public <H> HandlerRegistration addHandler(Type<H> type, H handler) {
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/WelcomeDialog.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/SettingsUtils.java
// public class SettingsUtils {
//
// public static final String PREF_TORCH_TIMEOUT = "pref_torch_timeout";
// public static final String PREF_TORCH_SOURCE = "pref_torch_source";
// public static final String PREF_VIBRATE = "pref_vibrate";
// private static final String PREF_FIRST_TIME = "pref_first_time";
// private static final String PREF_SCREEN_ON = "pref_screen_on";
// private static final String PREF_SCREEN_LOCK = "pref_screen_lock";
// private static final String PREF_SCREEN_OFF = "pref_screen_off_timeout";
// private static final String PREF_PROXIMITY = "pref_proximity";
//
// public static boolean isFirstTime(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_FIRST_TIME, true);
// }
//
// public static void setFirstTime(final Context context, final boolean newValue) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// sp.edit().putBoolean(SettingsUtils.PREF_FIRST_TIME, newValue).apply();
// }
//
// public static boolean isScreenOnEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_SCREEN_ON, context.getResources().getBoolean(R.bool.pref_default_screen_on));
// }
//
// public static boolean isScreenLockEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_SCREEN_LOCK, context.getResources().getBoolean(R.bool.pref_default_screen_lock));
// }
//
// public static boolean isScreenOffEnabled(final Context context) {
// int value = SettingsUtils.getScreenOffTimeoutSec(context);
// return value != 0;
// }
//
// public static boolean isScreenOffIndefinite(final Context context) {
// int value = SettingsUtils.getScreenOffTimeoutSec(context);
// return value == -1;
// }
//
// public static int getScreenOffTimeoutSec(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return Integer.parseInt(sp.getString(SettingsUtils.PREF_SCREEN_OFF, context.getResources().getString(R.string.pref_default_screen_off_timeout)));
// }
//
// public static boolean isTorchTimeoutIndefinite(final Context context) {
// int value = SettingsUtils.getTorchTimeout(context);
// return value == -1;
// }
//
// public static int getTorchTimeout(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return Integer.parseInt(sp.getString(SettingsUtils.PREF_TORCH_TIMEOUT, context.getResources().getString(R.string.pref_default_torch_timeout)));
// }
//
// public static String getTorchSource(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getString(SettingsUtils.PREF_TORCH_SOURCE, context.getResources().getString(R.string.pref_default_torch_source));
// }
//
// public static boolean isProximityEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_PROXIMITY, context.getResources().getBoolean(R.bool.pref_default_proximity));
// }
//
// public static boolean isVibrateEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_VIBRATE, context.getResources().getBoolean(R.bool.pref_default_vibrate));
// }
// }
|
import android.app.DialogFragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import in.blogspot.anselmbros.torchie.R;
import in.blogspot.anselmbros.torchie.utils.SettingsUtils;
|
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.ui.fragment.dialog;
/**
* Created by anselm94 on 8/12/15.
*/
public class WelcomeDialog extends DialogFragment implements View.OnClickListener {
View rootView;
Button but_dismiss;
public WelcomeDialog() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.dialog_welcome, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
but_dismiss = (Button) rootView.findViewById(R.id.but_welcome_dismiss);
but_dismiss.setOnClickListener(this);
return rootView;
}
@Override
public void onDestroyView() {
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/SettingsUtils.java
// public class SettingsUtils {
//
// public static final String PREF_TORCH_TIMEOUT = "pref_torch_timeout";
// public static final String PREF_TORCH_SOURCE = "pref_torch_source";
// public static final String PREF_VIBRATE = "pref_vibrate";
// private static final String PREF_FIRST_TIME = "pref_first_time";
// private static final String PREF_SCREEN_ON = "pref_screen_on";
// private static final String PREF_SCREEN_LOCK = "pref_screen_lock";
// private static final String PREF_SCREEN_OFF = "pref_screen_off_timeout";
// private static final String PREF_PROXIMITY = "pref_proximity";
//
// public static boolean isFirstTime(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_FIRST_TIME, true);
// }
//
// public static void setFirstTime(final Context context, final boolean newValue) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// sp.edit().putBoolean(SettingsUtils.PREF_FIRST_TIME, newValue).apply();
// }
//
// public static boolean isScreenOnEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_SCREEN_ON, context.getResources().getBoolean(R.bool.pref_default_screen_on));
// }
//
// public static boolean isScreenLockEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_SCREEN_LOCK, context.getResources().getBoolean(R.bool.pref_default_screen_lock));
// }
//
// public static boolean isScreenOffEnabled(final Context context) {
// int value = SettingsUtils.getScreenOffTimeoutSec(context);
// return value != 0;
// }
//
// public static boolean isScreenOffIndefinite(final Context context) {
// int value = SettingsUtils.getScreenOffTimeoutSec(context);
// return value == -1;
// }
//
// public static int getScreenOffTimeoutSec(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return Integer.parseInt(sp.getString(SettingsUtils.PREF_SCREEN_OFF, context.getResources().getString(R.string.pref_default_screen_off_timeout)));
// }
//
// public static boolean isTorchTimeoutIndefinite(final Context context) {
// int value = SettingsUtils.getTorchTimeout(context);
// return value == -1;
// }
//
// public static int getTorchTimeout(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return Integer.parseInt(sp.getString(SettingsUtils.PREF_TORCH_TIMEOUT, context.getResources().getString(R.string.pref_default_torch_timeout)));
// }
//
// public static String getTorchSource(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getString(SettingsUtils.PREF_TORCH_SOURCE, context.getResources().getString(R.string.pref_default_torch_source));
// }
//
// public static boolean isProximityEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_PROXIMITY, context.getResources().getBoolean(R.bool.pref_default_proximity));
// }
//
// public static boolean isVibrateEnabled(final Context context) {
// SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context);
// return sp.getBoolean(SettingsUtils.PREF_VIBRATE, context.getResources().getBoolean(R.bool.pref_default_vibrate));
// }
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/WelcomeDialog.java
import android.app.DialogFragment;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import in.blogspot.anselmbros.torchie.R;
import in.blogspot.anselmbros.torchie.utils.SettingsUtils;
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.ui.fragment.dialog;
/**
* Created by anselm94 on 8/12/15.
*/
public class WelcomeDialog extends DialogFragment implements View.OnClickListener {
View rootView;
Button but_dismiss;
public WelcomeDialog() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.dialog_welcome, container, false);
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
but_dismiss = (Button) rootView.findViewById(R.id.but_welcome_dismiss);
but_dismiss.setOnClickListener(this);
return rootView;
}
@Override
public void onDestroyView() {
|
SettingsUtils.setFirstTime(this.getActivity(), false);
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/wakelock/WakeLock.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/receiver/RockerReceiver.java
// public class RockerReceiver extends BroadcastReceiver {
// @Override
// public void onReceive(Context context, Intent intent) {
// if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
// final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
// if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) {
// switch (event.getKeyCode()) {
// case KeyEvent.KEYCODE_VOLUME_UP:
// if (this.isTorchieQuickServiceRunning()) {
// TorchieQuick.getInstance().setVolumeValues(1);
// }
// break;
// case KeyEvent.KEYCODE_VOLUME_DOWN:
// if (this.isTorchieQuickServiceRunning()) {
// TorchieQuick.getInstance().setVolumeValues(-1);
// }
// break;
// default:
// if (this.isTorchieQuickServiceRunning()) {
// TorchieQuick.getInstance().setVolumeValues(0);
// }
// }
// }
// }
// }
//
// private boolean isTorchieQuickServiceRunning() {
// return TorchieQuick.getInstance() != null;
// }
// }
|
import android.content.ComponentName;
import android.content.Context;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.media.VolumeProviderCompat;
import in.blogspot.anselmbros.torchie.receiver.RockerReceiver;
|
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.wakelock;
/**
* Created by Merbin J Anselm on 05-Feb-17.
*/
public class WakeLock {
public static final String TYPE = "in.blogspot.anselmbros.torchie.Wakelock";
private MediaSessionCompat mMediaSession;
private boolean isWakelockHeld;
private boolean isEnabled;
public WakeLock() {
this.isWakelockHeld = false;
this.isEnabled = true;
}
public void acquire(Context context, VolumeProviderCompat volumeProvider) {
if (!this.isWakelockHeld && this.isEnabled) {
if (this.mMediaSession == null) {
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/receiver/RockerReceiver.java
// public class RockerReceiver extends BroadcastReceiver {
// @Override
// public void onReceive(Context context, Intent intent) {
// if (Intent.ACTION_MEDIA_BUTTON.equals(intent.getAction())) {
// final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
// if (event != null && event.getAction() == KeyEvent.ACTION_DOWN) {
// switch (event.getKeyCode()) {
// case KeyEvent.KEYCODE_VOLUME_UP:
// if (this.isTorchieQuickServiceRunning()) {
// TorchieQuick.getInstance().setVolumeValues(1);
// }
// break;
// case KeyEvent.KEYCODE_VOLUME_DOWN:
// if (this.isTorchieQuickServiceRunning()) {
// TorchieQuick.getInstance().setVolumeValues(-1);
// }
// break;
// default:
// if (this.isTorchieQuickServiceRunning()) {
// TorchieQuick.getInstance().setVolumeValues(0);
// }
// }
// }
// }
// }
//
// private boolean isTorchieQuickServiceRunning() {
// return TorchieQuick.getInstance() != null;
// }
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/wakelock/WakeLock.java
import android.content.ComponentName;
import android.content.Context;
import android.support.v4.media.session.MediaSessionCompat;
import android.support.v4.media.session.PlaybackStateCompat;
import androidx.media.VolumeProviderCompat;
import in.blogspot.anselmbros.torchie.receiver.RockerReceiver;
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.wakelock;
/**
* Created by Merbin J Anselm on 05-Feb-17.
*/
public class WakeLock {
public static final String TYPE = "in.blogspot.anselmbros.torchie.Wakelock";
private MediaSessionCompat mMediaSession;
private boolean isWakelockHeld;
private boolean isEnabled;
public WakeLock() {
this.isWakelockHeld = false;
this.isEnabled = true;
}
public void acquire(Context context, VolumeProviderCompat volumeProvider) {
if (!this.isWakelockHeld && this.isEnabled) {
if (this.mMediaSession == null) {
|
ComponentName mediaReceiver = new ComponentName(context, RockerReceiver.class.getName());
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/flashlight/Flashlight2.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
|
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import in.blogspot.anselmbros.torchie.R;
import in.blogspot.anselmbros.torchie.utils.Constants;
|
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.device.output.torch.flashlight;
/**
* Created by Merbin J Anselm on 04-Feb-17.
*/
@TargetApi(23)
public class Flashlight2 extends Flashlight {
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/flashlight/Flashlight2.java
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import in.blogspot.anselmbros.torchie.R;
import in.blogspot.anselmbros.torchie.utils.Constants;
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.device.output.torch.flashlight;
/**
* Created by Merbin J Anselm on 04-Feb-17.
*/
@TargetApi(23)
public class Flashlight2 extends Flashlight {
|
public static final String TYPE = Constants.ID_DEVICE_OUTPUT_TORCH_FLASH_NEW;
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/WakeLockManager.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/wakelock/WakeLock.java
// public class WakeLock {
//
// public static final String TYPE = "in.blogspot.anselmbros.torchie.Wakelock";
//
// private MediaSessionCompat mMediaSession;
// private boolean isWakelockHeld;
// private boolean isEnabled;
//
// public WakeLock() {
// this.isWakelockHeld = false;
// this.isEnabled = true;
// }
//
// public void acquire(Context context, VolumeProviderCompat volumeProvider) {
// if (!this.isWakelockHeld && this.isEnabled) {
// if (this.mMediaSession == null) {
// ComponentName mediaReceiver = new ComponentName(context, RockerReceiver.class.getName());
// this.mMediaSession = new MediaSessionCompat(context, TYPE, mediaReceiver, null);
//
// this.mMediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
// MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
// this.mMediaSession.setPlaybackState(new PlaybackStateCompat.Builder()
// .setState(PlaybackStateCompat.STATE_PLAYING, 0, 0)
// .build());
// }
// this.mMediaSession.setPlaybackToRemote(volumeProvider);
// this.mMediaSession.setActive(true);
// this.isWakelockHeld = true;
// }
// }
//
// public void release() {
// if (this.isWakelockHeld && this.isEnabled) {
// if (this.mMediaSession != null) {
// this.mMediaSession.setActive(false);
// this.mMediaSession.release();
// this.mMediaSession = null;
// this.isWakelockHeld = false;
// }
// }
// }
//
// public boolean isHeld() {
// return this.isWakelockHeld;
// }
//
// public void setEnabled(boolean enabled) {
// this.isEnabled = enabled;
// }
// }
|
import android.content.Context;
import android.util.Log;
import androidx.media.VolumeProviderCompat;
import in.blogspot.anselmbros.torchie.main.manager.wakelock.WakeLock;
|
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager;
/**
* Created by Merbin J Anselm on 05-Feb-17.
*/
public class WakeLockManager {
private static WakeLockManager mInstance;
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/wakelock/WakeLock.java
// public class WakeLock {
//
// public static final String TYPE = "in.blogspot.anselmbros.torchie.Wakelock";
//
// private MediaSessionCompat mMediaSession;
// private boolean isWakelockHeld;
// private boolean isEnabled;
//
// public WakeLock() {
// this.isWakelockHeld = false;
// this.isEnabled = true;
// }
//
// public void acquire(Context context, VolumeProviderCompat volumeProvider) {
// if (!this.isWakelockHeld && this.isEnabled) {
// if (this.mMediaSession == null) {
// ComponentName mediaReceiver = new ComponentName(context, RockerReceiver.class.getName());
// this.mMediaSession = new MediaSessionCompat(context, TYPE, mediaReceiver, null);
//
// this.mMediaSession.setFlags(MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS |
// MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS);
// this.mMediaSession.setPlaybackState(new PlaybackStateCompat.Builder()
// .setState(PlaybackStateCompat.STATE_PLAYING, 0, 0)
// .build());
// }
// this.mMediaSession.setPlaybackToRemote(volumeProvider);
// this.mMediaSession.setActive(true);
// this.isWakelockHeld = true;
// }
// }
//
// public void release() {
// if (this.isWakelockHeld && this.isEnabled) {
// if (this.mMediaSession != null) {
// this.mMediaSession.setActive(false);
// this.mMediaSession.release();
// this.mMediaSession = null;
// this.isWakelockHeld = false;
// }
// }
// }
//
// public boolean isHeld() {
// return this.isWakelockHeld;
// }
//
// public void setEnabled(boolean enabled) {
// this.isEnabled = enabled;
// }
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/WakeLockManager.java
import android.content.Context;
import android.util.Log;
import androidx.media.VolumeProviderCompat;
import in.blogspot.anselmbros.torchie.main.manager.wakelock.WakeLock;
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2017 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager;
/**
* Created by Merbin J Anselm on 05-Feb-17.
*/
public class WakeLockManager {
private static WakeLockManager mInstance;
|
private WakeLock wakeLock;
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/screenlight/Screenlight.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/Torch.java
// public abstract class Torch extends OutputDevice {
// public static final String TYPE = Constants.ID_DEVICE_OUTPUT_TORCH;
//
// public Torch(Context context) {
// super(context);
// this.deviceType = TYPE;
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/activity/ScreenflashActivity.java
// public class ScreenflashActivity extends Activity {
//
// CloseActivityReceiver closeActivityReceiver;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
//
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
// WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
// WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
// WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_screenflash);
//
// setScreenBrightness(1f);
//
// closeActivityReceiver = new CloseActivityReceiver();
// registerReceiver(closeActivityReceiver, new IntentFilter(CLOSE_ACTIVITY_IDENTIFIER));
// }
//
// @Override
// protected void onPause() {
// overridePendingTransition(0, 0); //Disable exit animation
// super.onPause();
// }
//
// @Override
// protected void onDestroy() {
// unregisterReceiver(closeActivityReceiver);
// super.onDestroy();
// }
//
// private void setScreenBrightness(float value) {
// WindowManager.LayoutParams lp = getWindow().getAttributes();
// lp.screenBrightness = value; // 0f - no backlight ... 1f - full backlight
// getWindow().setAttributes(lp);
// }
//
// public class CloseActivityReceiver extends BroadcastReceiver {
// @Override
// public void onReceive(Context context, Intent intent) {
// if (intent.getAction().equals(CLOSE_ACTIVITY_IDENTIFIER)) {
// finish();
// }
// }
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
|
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import in.blogspot.anselmbros.torchie.main.manager.device.output.torch.Torch;
import in.blogspot.anselmbros.torchie.ui.activity.ScreenflashActivity;
import in.blogspot.anselmbros.torchie.utils.Constants;
|
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.device.output.torch.screenlight;
/**
* Created by Merbin J Anselm on 04-Feb-17.
*/
public class Screenlight extends Torch {
public static final String TYPE = Constants.ID_DEVICE_OUTPUT_TORCH_SCREEN;
public final static String CLOSE_ACTIVITY_IDENTIFIER = "in.blogspot.anselmbros.torchie.CLOSE_ACTIVITY";
private ScreenlightOffReceiver screenlightOffReceiver;
public Screenlight(Context context) {
super(context);
this.deviceType = TYPE;
}
@Override
protected void turnOn() {
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/Torch.java
// public abstract class Torch extends OutputDevice {
// public static final String TYPE = Constants.ID_DEVICE_OUTPUT_TORCH;
//
// public Torch(Context context) {
// super(context);
// this.deviceType = TYPE;
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/activity/ScreenflashActivity.java
// public class ScreenflashActivity extends Activity {
//
// CloseActivityReceiver closeActivityReceiver;
//
// @Override
// protected void onCreate(Bundle savedInstanceState) {
//
// requestWindowFeature(Window.FEATURE_NO_TITLE);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
// WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
// WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
// WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
//
// super.onCreate(savedInstanceState);
// setContentView(R.layout.activity_screenflash);
//
// setScreenBrightness(1f);
//
// closeActivityReceiver = new CloseActivityReceiver();
// registerReceiver(closeActivityReceiver, new IntentFilter(CLOSE_ACTIVITY_IDENTIFIER));
// }
//
// @Override
// protected void onPause() {
// overridePendingTransition(0, 0); //Disable exit animation
// super.onPause();
// }
//
// @Override
// protected void onDestroy() {
// unregisterReceiver(closeActivityReceiver);
// super.onDestroy();
// }
//
// private void setScreenBrightness(float value) {
// WindowManager.LayoutParams lp = getWindow().getAttributes();
// lp.screenBrightness = value; // 0f - no backlight ... 1f - full backlight
// getWindow().setAttributes(lp);
// }
//
// public class CloseActivityReceiver extends BroadcastReceiver {
// @Override
// public void onReceive(Context context, Intent intent) {
// if (intent.getAction().equals(CLOSE_ACTIVITY_IDENTIFIER)) {
// finish();
// }
// }
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/screenlight/Screenlight.java
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import in.blogspot.anselmbros.torchie.main.manager.device.output.torch.Torch;
import in.blogspot.anselmbros.torchie.ui.activity.ScreenflashActivity;
import in.blogspot.anselmbros.torchie.utils.Constants;
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.device.output.torch.screenlight;
/**
* Created by Merbin J Anselm on 04-Feb-17.
*/
public class Screenlight extends Torch {
public static final String TYPE = Constants.ID_DEVICE_OUTPUT_TORCH_SCREEN;
public final static String CLOSE_ACTIVITY_IDENTIFIER = "in.blogspot.anselmbros.torchie.CLOSE_ACTIVITY";
private ScreenlightOffReceiver screenlightOffReceiver;
public Screenlight(Context context) {
super(context);
this.deviceType = TYPE;
}
@Override
protected void turnOn() {
|
Intent intent = new Intent(this.mContext, ScreenflashActivity.class);
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/DonateSuccessDialog.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
|
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import in.blogspot.anselmbros.torchie.R;
import in.blogspot.anselmbros.torchie.utils.Constants;
|
butDismiss = (Button) rootView.findViewById(R.id.but_thanks_dismiss);
butShare = (Button) rootView.findViewById(R.id.but_thanks_share);
butDismiss.setOnClickListener(this);
butShare.setOnClickListener(this);
return rootView;
}
@Override
public void onClick(View v) {
if (v == butDismiss) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, 350L);
} else if (v == butShare) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent int_tell = new Intent(Intent.ACTION_SEND);
int_tell.setType("text/plain");
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/DonateSuccessDialog.java
import android.app.DialogFragment;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import in.blogspot.anselmbros.torchie.R;
import in.blogspot.anselmbros.torchie.utils.Constants;
butDismiss = (Button) rootView.findViewById(R.id.but_thanks_dismiss);
butShare = (Button) rootView.findViewById(R.id.but_thanks_share);
butDismiss.setOnClickListener(this);
butShare.setOnClickListener(this);
return rootView;
}
@Override
public void onClick(View v) {
if (v == butDismiss) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, 350L);
} else if (v == butShare) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent int_tell = new Intent(Intent.ACTION_SEND);
int_tell.setType("text/plain");
|
int_tell.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.share_info) + Constants.PLAY_URI);
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/DonateFailDialog.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
|
import in.blogspot.anselmbros.torchie.utils.Constants;
import android.app.DialogFragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import in.blogspot.anselmbros.torchie.R;
|
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
butDismiss = (Button) rootView.findViewById(R.id.but_error_dismiss);
butProceed = (Button) rootView.findViewById(R.id.but_proceed_paypal);
butDismiss.setOnClickListener(this);
butProceed.setOnClickListener(this);
return rootView;
}
@Override
public void onClick(View v) {
if (v == butDismiss) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, 350L);
} else if (v == butProceed) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(Intent.ACTION_VIEW);
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/DonateFailDialog.java
import in.blogspot.anselmbros.torchie.utils.Constants;
import android.app.DialogFragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.Button;
import in.blogspot.anselmbros.torchie.R;
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
butDismiss = (Button) rootView.findViewById(R.id.but_error_dismiss);
butProceed = (Button) rootView.findViewById(R.id.but_proceed_paypal);
butDismiss.setOnClickListener(this);
butProceed.setOnClickListener(this);
return rootView;
}
@Override
public void onClick(View v) {
if (v == butDismiss) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
dismiss();
}
}, 350L);
} else if (v == butProceed) {
Handler mHandler = new Handler();
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(Intent.ACTION_VIEW);
|
intent.setData(Uri.parse(Constants.WEB_DONATE_URI));
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/ui/activity/ScreenflashActivity.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/screenlight/Screenlight.java
// public final static String CLOSE_ACTIVITY_IDENTIFIER = "in.blogspot.anselmbros.torchie.CLOSE_ACTIVITY";
|
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import in.blogspot.anselmbros.torchie.R;
import static in.blogspot.anselmbros.torchie.main.manager.device.output.torch.screenlight.Screenlight.CLOSE_ACTIVITY_IDENTIFIER;
|
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.ui.activity;
public class ScreenflashActivity extends Activity {
CloseActivityReceiver closeActivityReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screenflash);
setScreenBrightness(1f);
closeActivityReceiver = new CloseActivityReceiver();
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/output/torch/screenlight/Screenlight.java
// public final static String CLOSE_ACTIVITY_IDENTIFIER = "in.blogspot.anselmbros.torchie.CLOSE_ACTIVITY";
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/activity/ScreenflashActivity.java
import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import in.blogspot.anselmbros.torchie.R;
import static in.blogspot.anselmbros.torchie.main.manager.device.output.torch.screenlight.Screenlight.CLOSE_ACTIVITY_IDENTIFIER;
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.ui.activity;
public class ScreenflashActivity extends Activity {
CloseActivityReceiver closeActivityReceiver;
@Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD |
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON |
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screenflash);
setScreenBrightness(1f);
closeActivityReceiver = new CloseActivityReceiver();
|
registerReceiver(closeActivityReceiver, new IntentFilter(CLOSE_ACTIVITY_IDENTIFIER));
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/input/proximity/ProximitySensor.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/input/InputDevice.java
// public abstract class InputDevice extends Device {
// public static final String TYPE = Constants.ID_DEVICE_INPUT;
// public final static int INP_LOW = 0;
// public final static int INP_HIGH = 1;
// public final static int INP_TRIGGER = 2;
// private InputDeviceListener mListener;
//
// public InputDevice(Context context) {
// super(context);
// this.deviceType = TYPE;
// }
//
// public final void setListener(InputDeviceListener listener) {
// this.mListener = listener;
// }
//
// public final boolean setInputEvent(InputEvent event) {
// if (this.isEnabled) {
// return this.setEvent(event);
// }
// return false;
// }
//
// protected abstract boolean setEvent(InputEvent event);
//
// public abstract void getStatusRequest();
//
// protected final void updateCurrentSignal(int signal) {
// if (this.mListener != null) {
// this.mListener.onValueChanged(this.deviceType, signal);
// }
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/timer/CountTimer.java
// public class CountTimer extends CountDownTimer {
//
// private CountTimerListener mListener;
// private String id;
//
// public CountTimer(String id, double seconds, CountTimerListener listener) {
// super((long) (seconds * 1000), (long) (seconds * 1000));
// this.id = id;
// this.mListener = listener;
// }
//
// @Override
// public void onTick(long millisUntilFinished) {
//
// }
//
// @Override
// public void onFinish() {
// if (this.mListener != null) {
// this.mListener.onCountEnd(this.id);
// }
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/timer/CountTimerListener.java
// public interface CountTimerListener {
// void onCountEnd(String id);
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
|
import static android.content.Context.SENSOR_SERVICE;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.view.InputEvent;
import in.blogspot.anselmbros.torchie.main.manager.device.input.InputDevice;
import in.blogspot.anselmbros.torchie.main.manager.timer.CountTimer;
import in.blogspot.anselmbros.torchie.main.manager.timer.CountTimerListener;
import in.blogspot.anselmbros.torchie.utils.Constants;
|
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.device.input.proximity;
/**
* Created by Merbin J Anselm on 04-Feb-17.
*/
public class ProximitySensor extends InputDevice implements SensorEventListener, CountTimerListener {
public static final String TYPE = Constants.ID_DEVICE_INPUT_PROXIMITY;
private static ProximitySensor mInstance;
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/input/InputDevice.java
// public abstract class InputDevice extends Device {
// public static final String TYPE = Constants.ID_DEVICE_INPUT;
// public final static int INP_LOW = 0;
// public final static int INP_HIGH = 1;
// public final static int INP_TRIGGER = 2;
// private InputDeviceListener mListener;
//
// public InputDevice(Context context) {
// super(context);
// this.deviceType = TYPE;
// }
//
// public final void setListener(InputDeviceListener listener) {
// this.mListener = listener;
// }
//
// public final boolean setInputEvent(InputEvent event) {
// if (this.isEnabled) {
// return this.setEvent(event);
// }
// return false;
// }
//
// protected abstract boolean setEvent(InputEvent event);
//
// public abstract void getStatusRequest();
//
// protected final void updateCurrentSignal(int signal) {
// if (this.mListener != null) {
// this.mListener.onValueChanged(this.deviceType, signal);
// }
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/timer/CountTimer.java
// public class CountTimer extends CountDownTimer {
//
// private CountTimerListener mListener;
// private String id;
//
// public CountTimer(String id, double seconds, CountTimerListener listener) {
// super((long) (seconds * 1000), (long) (seconds * 1000));
// this.id = id;
// this.mListener = listener;
// }
//
// @Override
// public void onTick(long millisUntilFinished) {
//
// }
//
// @Override
// public void onFinish() {
// if (this.mListener != null) {
// this.mListener.onCountEnd(this.id);
// }
// }
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/timer/CountTimerListener.java
// public interface CountTimerListener {
// void onCountEnd(String id);
// }
//
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/main/manager/device/input/proximity/ProximitySensor.java
import static android.content.Context.SENSOR_SERVICE;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.view.InputEvent;
import in.blogspot.anselmbros.torchie.main.manager.device.input.InputDevice;
import in.blogspot.anselmbros.torchie.main.manager.timer.CountTimer;
import in.blogspot.anselmbros.torchie.main.manager.timer.CountTimerListener;
import in.blogspot.anselmbros.torchie.utils.Constants;
/*
* Copyright (C) 2016 Merbin J Anselm <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package in.blogspot.anselmbros.torchie.main.manager.device.input.proximity;
/**
* Created by Merbin J Anselm on 04-Feb-17.
*/
public class ProximitySensor extends InputDevice implements SensorEventListener, CountTimerListener {
public static final String TYPE = Constants.ID_DEVICE_INPUT_PROXIMITY;
private static ProximitySensor mInstance;
|
private CountTimer mCountTimer;
|
anselm94/Torchie-Android
|
app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/AboutDialog.java
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
|
import in.blogspot.anselmbros.torchie.utils.Constants;
import android.app.DialogFragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;
import in.blogspot.anselmbros.torchie.R;
|
tvAboutNote = (TextView) rootView.findViewById(R.id.tv_about_note);
tvAboutAnselm = (TextView) rootView.findViewById(R.id.tv_about_anselm);
tvVisitSite = (TextView) rootView.findViewById(R.id.tv_visit_site);
tvFacebook = (TextView) rootView.findViewById(R.id.tv_facebook);
tvTranslatorNote = (TextView) rootView.findViewById(R.id.tv_translator_note);
tvNotice = (TextView) rootView.findViewById(R.id.tv_notice);
tvAboutNote.setMovementMethod(LinkMovementMethod.getInstance());
tvTranslatorNote.setMovementMethod(LinkMovementMethod.getInstance());
tvAboutAnselm.setOnClickListener(this);
tvVisitSite.setOnClickListener(this);
tvFacebook.setOnClickListener(this);
tvNotice.setMovementMethod(LinkMovementMethod.getInstance());
try {
notice = String.format(getActivity().getResources().getString(R.string.notice), getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName);
tvNotice.setText(notice);
} catch (Exception e) {
notice = getActivity().getResources().getString(R.string.notice);
tvNotice.setText(notice);
}
return rootView;
}
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
if (v == tvAboutAnselm) {
|
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/utils/Constants.java
// public class Constants {
// public final static String ID_DEVICE = "0";
//
// public final static String ID_DEVICE_OUTPUT = "1";
// public final static String ID_DEVICE_OUTPUT_TORCH = "10";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH = "11";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_LEGACY = "12";
// public final static String ID_DEVICE_OUTPUT_TORCH_FLASH_NEW = "13";
// public final static String ID_DEVICE_OUTPUT_TORCH_SCREEN = "14";
// public final static String ID_DEVICE_OUTPUT_VIBRATOR = "15";
//
// public final static String ID_DEVICE_INPUT = "2";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY = "20";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_NATIVE = "21";
// public final static String ID_DEVICE_INPUT_VOLUMEKEY_ROCKER = "22";
// public final static String ID_DEVICE_INPUT_PROXIMITY = "23";
//
// public final static String PLAY_URI = "https://play.google.com/store/apps/details?id=in.blogspot.anselmbros.torchie";
// public final static String WEB_URI = "https://torchieapp.wordpress.com";
// public final static String ABOUTANSELM_URI = "https://anselm.in";
// public final static String FACEBOOK_URI = "https://facebook.com/torchieapp";
// public final static String WEB_DONATE_URI = "https://torchieapp.wordpress.com/donate/";
// }
// Path: app/src/main/java/in/blogspot/anselmbros/torchie/ui/fragment/dialog/AboutDialog.java
import in.blogspot.anselmbros.torchie.utils.Constants;
import android.app.DialogFragment;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.method.LinkMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;
import in.blogspot.anselmbros.torchie.R;
tvAboutNote = (TextView) rootView.findViewById(R.id.tv_about_note);
tvAboutAnselm = (TextView) rootView.findViewById(R.id.tv_about_anselm);
tvVisitSite = (TextView) rootView.findViewById(R.id.tv_visit_site);
tvFacebook = (TextView) rootView.findViewById(R.id.tv_facebook);
tvTranslatorNote = (TextView) rootView.findViewById(R.id.tv_translator_note);
tvNotice = (TextView) rootView.findViewById(R.id.tv_notice);
tvAboutNote.setMovementMethod(LinkMovementMethod.getInstance());
tvTranslatorNote.setMovementMethod(LinkMovementMethod.getInstance());
tvAboutAnselm.setOnClickListener(this);
tvVisitSite.setOnClickListener(this);
tvFacebook.setOnClickListener(this);
tvNotice.setMovementMethod(LinkMovementMethod.getInstance());
try {
notice = String.format(getActivity().getResources().getString(R.string.notice), getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(), 0).versionName);
tvNotice.setText(notice);
} catch (Exception e) {
notice = getActivity().getResources().getString(R.string.notice);
tvNotice.setText(notice);
}
return rootView;
}
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW);
if (v == tvAboutAnselm) {
|
intent.setData(Uri.parse(Constants.ABOUTANSELM_URI));
|
aksalj/africastalking-java
|
libs/core/src/main/java/com/africastalking/AT.java
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.account.AccountResponse;
import java.io.IOException;
|
package com.africastalking;
public final class AT {
private static void log(String message) {
System.out.println(message);
}
public static void main(String[] argv) {
log("\nAfrica's Talking SDK\n");
AfricasTalking.initialize(argv[0], argv[1]);
try {
log("\tGetting app account info...\n");
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/core/src/main/java/com/africastalking/AT.java
import com.africastalking.account.AccountResponse;
import java.io.IOException;
package com.africastalking;
public final class AT {
private static void log(String message) {
System.out.println(message);
}
public static void main(String[] argv) {
log("\nAfrica's Talking SDK\n");
AfricasTalking.initialize(argv[0], argv[1]);
try {
log("\tGetting app account info...\n");
|
AccountResponse resp = AfricasTalking.getService(AccountService.class).fetchAccount();
|
aksalj/africastalking-java
|
libs/token/src/main/java/com/africastalking/IToken.java
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Body;
|
package com.africastalking;
interface IToken {
@FormUrlEncoded
@POST("checkout/token/create")
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/token/src/main/java/com/africastalking/IToken.java
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Body;
package com.africastalking;
interface IToken {
@FormUrlEncoded
@POST("checkout/token/create")
|
Call<CheckoutTokenResponse> createCheckoutToken(@Field("phoneNumber") String phoneNumber);
|
aksalj/africastalking-java
|
libs/token/src/main/java/com/africastalking/IToken.java
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Body;
|
package com.africastalking;
interface IToken {
@FormUrlEncoded
@POST("checkout/token/create")
Call<CheckoutTokenResponse> createCheckoutToken(@Field("phoneNumber") String phoneNumber);
@Headers("Content-Type: application/json")
@POST("auth-token/generate")
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/token/src/main/java/com/africastalking/IToken.java
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.Body;
package com.africastalking;
interface IToken {
@FormUrlEncoded
@POST("checkout/token/create")
Call<CheckoutTokenResponse> createCheckoutToken(@Field("phoneNumber") String phoneNumber);
@Headers("Content-Type: application/json")
@POST("auth-token/generate")
|
Call<AuthTokenResponse> generateAuthToken(@Body String body);
|
aksalj/africastalking-java
|
libs/payment/src/main/java/com/africastalking/IPayment.java
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
|
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/payment/src/main/java/com/africastalking/IPayment.java
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
|
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
|
aksalj/africastalking-java
|
libs/payment/src/main/java/com/africastalking/IPayment.java
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
|
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
@POST("mobile/b2b/request")
Call<B2BResponse> requestB2B(@Body HashMap<String, Object> body);
@POST("mobile/checkout/request")
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/payment/src/main/java/com/africastalking/IPayment.java
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
@POST("mobile/b2b/request")
Call<B2BResponse> requestB2B(@Body HashMap<String, Object> body);
@POST("mobile/checkout/request")
|
Call<CheckoutResponse> mobileCheckout(@Body HashMap<String, Object> body);
|
aksalj/africastalking-java
|
libs/payment/src/main/java/com/africastalking/IPayment.java
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
|
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
@POST("mobile/b2b/request")
Call<B2BResponse> requestB2B(@Body HashMap<String, Object> body);
@POST("mobile/checkout/request")
Call<CheckoutResponse> mobileCheckout(@Body HashMap<String, Object> body);
@POST("card/checkout/charge")
Call<CheckoutResponse> cardCheckoutCharge(@Body HashMap<String, Object> body);
@POST("card/checkout/validate")
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/payment/src/main/java/com/africastalking/IPayment.java
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
@POST("mobile/b2b/request")
Call<B2BResponse> requestB2B(@Body HashMap<String, Object> body);
@POST("mobile/checkout/request")
Call<CheckoutResponse> mobileCheckout(@Body HashMap<String, Object> body);
@POST("card/checkout/charge")
Call<CheckoutResponse> cardCheckoutCharge(@Body HashMap<String, Object> body);
@POST("card/checkout/validate")
|
Call<CheckoutValidateResponse> cardCheckoutValidate(@Body HashMap<String, Object> body);
|
aksalj/africastalking-java
|
libs/payment/src/main/java/com/africastalking/IPayment.java
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
|
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
@POST("mobile/b2b/request")
Call<B2BResponse> requestB2B(@Body HashMap<String, Object> body);
@POST("mobile/checkout/request")
Call<CheckoutResponse> mobileCheckout(@Body HashMap<String, Object> body);
@POST("card/checkout/charge")
Call<CheckoutResponse> cardCheckoutCharge(@Body HashMap<String, Object> body);
@POST("card/checkout/validate")
Call<CheckoutValidateResponse> cardCheckoutValidate(@Body HashMap<String, Object> body);
@POST("bank/checkout/charge")
Call<CheckoutResponse> bankCheckoutCharge(@Body HashMap<String, Object> body);
@POST("bank/checkout/validate")
Call<CheckoutValidateResponse> bankCheckoutValidate(@Body HashMap<String, Object> body);
@POST("bank/transfer")
|
// Path: libs/payment/src/main/java/com/africastalking/payment/response/B2CResponse.java
// public final class B2CResponse {
//
// public int numQueued;
// public String totalValue;
// public String totalTransactionFee;
// public List<B2CEntry> entries;
//
//
// public static class B2CEntry {
// public String phoneNumber;
// public String status;
// public String provider;
// public String providerChannel;
// public String value;
// public String transactionId;
// public String transactionFee;
// public String errorMessage = null;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/BankTransferResponse.java
// public final class BankTransferResponse {
// public String errorMessage;
// public List<BankEntries> entries;
//
// public static final class BankEntries {
// public String accountNumber;
// public String status;
// public String transactionId;
// public String transactionFee;
// public String errorMessage;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutValidateResponse.java
// public final class CheckoutValidateResponse {
//
// /**
// * Status
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
// /**
// * Optional checkout token
// */
// public String checkoutToken;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/payment/src/main/java/com/africastalking/payment/response/CheckoutResponse.java
// public final class CheckoutResponse {
//
// /**
// * Unique transaction ID
// */
// public String transactionId;
// /**
// * Transaction status e.g. CheckoutResponse.STATUS_PENDING
// */
// public String status;
//
// /**
// * Status description
// */
// public String description;
//
//
// /**
// * Optional checkout token
// */
// public String checkoutToken = null;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/payment/src/main/java/com/africastalking/IPayment.java
import com.africastalking.payment.response.B2BResponse;
import com.africastalking.payment.response.B2CResponse;
import com.africastalking.payment.response.BankTransferResponse;
import com.africastalking.payment.response.CheckoutValidateResponse;
import com.africastalking.payment.response.CheckoutResponse;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.POST;
import java.util.HashMap;
package com.africastalking;
interface IPayment {
@POST("mobile/b2c/request")
Call<B2CResponse> requestB2C(@Body HashMap<String, Object> body);
@POST("mobile/b2b/request")
Call<B2BResponse> requestB2B(@Body HashMap<String, Object> body);
@POST("mobile/checkout/request")
Call<CheckoutResponse> mobileCheckout(@Body HashMap<String, Object> body);
@POST("card/checkout/charge")
Call<CheckoutResponse> cardCheckoutCharge(@Body HashMap<String, Object> body);
@POST("card/checkout/validate")
Call<CheckoutValidateResponse> cardCheckoutValidate(@Body HashMap<String, Object> body);
@POST("bank/checkout/charge")
Call<CheckoutResponse> bankCheckoutCharge(@Body HashMap<String, Object> body);
@POST("bank/checkout/validate")
Call<CheckoutValidateResponse> bankCheckoutValidate(@Body HashMap<String, Object> body);
@POST("bank/transfer")
|
Call<BankTransferResponse> bankTransfer(@Body HashMap<String, Object> body);
|
aksalj/africastalking-java
|
libs/account/src/main/java/com/africastalking/IAccount.java
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.account.AccountResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
|
package com.africastalking;
/**
* Account Endpoints
*/
interface IAccount {
@GET("user")
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/account/src/main/java/com/africastalking/IAccount.java
import com.africastalking.account.AccountResponse;
import retrofit2.Call;
import retrofit2.http.GET;
import retrofit2.http.Query;
package com.africastalking;
/**
* Account Endpoints
*/
interface IAccount {
@GET("user")
|
Call<AccountResponse> fetchAccount(@Query("username") String username);
|
aksalj/africastalking-java
|
libs/token/src/main/java/com/africastalking/TokenService.java
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Response;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
|
@Override
protected TokenService getInstance(String username, String apiKey) {
if(sInstance == null) {
sInstance = new TokenService(username, apiKey);
}
return sInstance;
}
@Override
protected boolean isInitialized() {
return sInstance != null;
}
@Override
protected void initService() {
String baseUrl = "https://api."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
service = mRetrofitBuilder
.baseUrl(baseUrl)
.build()
.create(IToken.class);
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/token/src/main/java/com/africastalking/TokenService.java
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Response;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
@Override
protected TokenService getInstance(String username, String apiKey) {
if(sInstance == null) {
sInstance = new TokenService(username, apiKey);
}
return sInstance;
}
@Override
protected boolean isInitialized() {
return sInstance != null;
}
@Override
protected void initService() {
String baseUrl = "https://api."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
service = mRetrofitBuilder
.baseUrl(baseUrl)
.build()
.create(IToken.class);
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
|
public CheckoutTokenResponse createCheckoutToken(String phoneNumber) throws IOException {
|
aksalj/africastalking-java
|
libs/token/src/main/java/com/africastalking/TokenService.java
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Response;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
|
@Override
protected void initService() {
String baseUrl = "https://api."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
service = mRetrofitBuilder
.baseUrl(baseUrl)
.build()
.create(IToken.class);
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
public CheckoutTokenResponse createCheckoutToken(String phoneNumber) throws IOException {
Response<CheckoutTokenResponse> resp = service.createCheckoutToken(phoneNumber).execute();
if (!resp.isSuccessful()) {
throw new IOException(resp.errorBody().string());
}
return resp.body();
}
public void createCheckoutToken(String phoneNumber, Callback<CheckoutTokenResponse> callback) {
service.createCheckoutToken(phoneNumber).enqueue(makeCallback(callback));
}
|
// Path: libs/token/src/main/java/com/africastalking/token/AuthTokenResponse.java
// public final class AuthTokenResponse {
// public String token;
// public long lifetimeInSeconds;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/token/src/main/java/com/africastalking/token/CheckoutTokenResponse.java
// public final class CheckoutTokenResponse {
// public String token;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: libs/token/src/main/java/com/africastalking/TokenService.java
import com.africastalking.token.AuthTokenResponse;
import com.africastalking.token.CheckoutTokenResponse;
import retrofit2.Response;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
@Override
protected void initService() {
String baseUrl = "https://api."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
service = mRetrofitBuilder
.baseUrl(baseUrl)
.build()
.create(IToken.class);
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
public CheckoutTokenResponse createCheckoutToken(String phoneNumber) throws IOException {
Response<CheckoutTokenResponse> resp = service.createCheckoutToken(phoneNumber).execute();
if (!resp.isSuccessful()) {
throw new IOException(resp.errorBody().string());
}
return resp.body();
}
public void createCheckoutToken(String phoneNumber, Callback<CheckoutTokenResponse> callback) {
service.createCheckoutToken(phoneNumber).enqueue(makeCallback(callback));
}
|
public AuthTokenResponse generateAuthToken() throws IOException {
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/account/AccountTest.java
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
|
import com.africastalking.*;
import com.africastalking.account.AccountResponse;
import com.africastalking.test.Fixtures;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
|
package com.africastalking.test.account;
public class AccountTest {
CountDownLatch lock;
@Before
public void setup() {
lock = new CountDownLatch(10);
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// Path: libs/core/src/test/java/com/africastalking/test/account/AccountTest.java
import com.africastalking.*;
import com.africastalking.account.AccountResponse;
import com.africastalking.test.Fixtures;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
package com.africastalking.test.account;
public class AccountTest {
CountDownLatch lock;
@Before
public void setup() {
lock = new CountDownLatch(10);
|
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/account/AccountTest.java
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
|
import com.africastalking.*;
import com.africastalking.account.AccountResponse;
import com.africastalking.test.Fixtures;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
|
package com.africastalking.test.account;
public class AccountTest {
CountDownLatch lock;
@Before
public void setup() {
lock = new CountDownLatch(10);
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
}
@Test
public void testFetchAccount() {
AccountService service = AfricasTalking.getService(AccountService.class);
try {
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
// Path: libs/core/src/test/java/com/africastalking/test/account/AccountTest.java
import com.africastalking.*;
import com.africastalking.account.AccountResponse;
import com.africastalking.test.Fixtures;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertEquals;
package com.africastalking.test.account;
public class AccountTest {
CountDownLatch lock;
@Before
public void setup() {
lock = new CountDownLatch(10);
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
}
@Test
public void testFetchAccount() {
AccountService service = AfricasTalking.getService(AccountService.class);
try {
|
final AccountResponse resp = service.fetchAccount();
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/ISMS.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
|
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/ISMS.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
|
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/ISMS.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
|
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("bulkSMSMode") int bulkMode, @Field("enqueue") String enqueue);
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> sendPremium(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("keyword") String keyword, @Field("linkId") String linkId,
@Field("retryDurationInHours") String retryDurationInHours,
@Field("bulkSMSMode") int bulkMode);
@GET("messaging")
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/ISMS.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("bulkSMSMode") int bulkMode, @Field("enqueue") String enqueue);
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> sendPremium(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("keyword") String keyword, @Field("linkId") String linkId,
@Field("retryDurationInHours") String retryDurationInHours,
@Field("bulkSMSMode") int bulkMode);
@GET("messaging")
|
Call<FetchMessageResponse> fetchMessages(@Query("username") String username, @Query("lastReceivedId") String lastReceivedId);
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/ISMS.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
|
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("bulkSMSMode") int bulkMode, @Field("enqueue") String enqueue);
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> sendPremium(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("keyword") String keyword, @Field("linkId") String linkId,
@Field("retryDurationInHours") String retryDurationInHours,
@Field("bulkSMSMode") int bulkMode);
@GET("messaging")
Call<FetchMessageResponse> fetchMessages(@Query("username") String username, @Query("lastReceivedId") String lastReceivedId);
@GET("subscription")
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/ISMS.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("bulkSMSMode") int bulkMode, @Field("enqueue") String enqueue);
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> sendPremium(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("keyword") String keyword, @Field("linkId") String linkId,
@Field("retryDurationInHours") String retryDurationInHours,
@Field("bulkSMSMode") int bulkMode);
@GET("messaging")
Call<FetchMessageResponse> fetchMessages(@Query("username") String username, @Query("lastReceivedId") String lastReceivedId);
@GET("subscription")
|
Call<FetchSubscriptionResponse> fetchSubscriptions(@Query("username") String username, @Query("shortCode") String shortCode,
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/ISMS.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
|
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("bulkSMSMode") int bulkMode, @Field("enqueue") String enqueue);
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> sendPremium(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("keyword") String keyword, @Field("linkId") String linkId,
@Field("retryDurationInHours") String retryDurationInHours,
@Field("bulkSMSMode") int bulkMode);
@GET("messaging")
Call<FetchMessageResponse> fetchMessages(@Query("username") String username, @Query("lastReceivedId") String lastReceivedId);
@GET("subscription")
Call<FetchSubscriptionResponse> fetchSubscriptions(@Query("username") String username, @Query("shortCode") String shortCode,
@Query("keyword") String keyword, @Query("lastReceivedId") String lastReceivedId);
@FormUrlEncoded
@POST("subscription/create")
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/ISMS.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Call;
import retrofit2.http.*;
package com.africastalking;
interface ISMS {
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> send(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("bulkSMSMode") int bulkMode, @Field("enqueue") String enqueue);
@FormUrlEncoded
@POST("messaging")
Call<SendMessageResponse> sendPremium(@Field("username") String username, @Field("to") String to,
@Field("from") String from, @Field("message") String message,
@Field("keyword") String keyword, @Field("linkId") String linkId,
@Field("retryDurationInHours") String retryDurationInHours,
@Field("bulkSMSMode") int bulkMode);
@GET("messaging")
Call<FetchMessageResponse> fetchMessages(@Query("username") String username, @Query("lastReceivedId") String lastReceivedId);
@GET("subscription")
Call<FetchSubscriptionResponse> fetchSubscriptions(@Query("username") String username, @Query("shortCode") String shortCode,
@Query("keyword") String keyword, @Query("lastReceivedId") String lastReceivedId);
@FormUrlEncoded
@POST("subscription/create")
|
Call<SubscriptionResponse> createSubscription(@Field("username") String username, @Field("shortCode") String shortCode,
|
aksalj/africastalking-java
|
libs/voice/src/main/java/com/africastalking/IVoice.java
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.http.*;
|
package com.africastalking;
interface IVoice {
@FormUrlEncoded
@POST("call")
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/voice/src/main/java/com/africastalking/IVoice.java
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.http.*;
package com.africastalking;
interface IVoice {
@FormUrlEncoded
@POST("call")
|
Call<CallResponse> call(@Field("username") String username, @Field("to") String to,
|
aksalj/africastalking-java
|
libs/voice/src/main/java/com/africastalking/IVoice.java
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.http.*;
|
package com.africastalking;
interface IVoice {
@FormUrlEncoded
@POST("call")
Call<CallResponse> call(@Field("username") String username, @Field("to") String to,
@Field("from") String from);
@FormUrlEncoded
@POST("/queueStatus")
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/voice/src/main/java/com/africastalking/IVoice.java
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.http.*;
package com.africastalking;
interface IVoice {
@FormUrlEncoded
@POST("call")
Call<CallResponse> call(@Field("username") String username, @Field("to") String to,
@Field("from") String from);
@FormUrlEncoded
@POST("/queueStatus")
|
Call<QueuedCallsResponse> queueStatus(@Field("username") String username, @Field("phoneNumbers") String phoneNumbers);
|
aksalj/africastalking-java
|
libs/voice/src/main/java/com/africastalking/VoiceService.java
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.Response;
import java.io.IOException;
|
}
@Override
protected boolean isInitialized() {
return sInstance != null;
}
@Override
protected void initService() {
String baseUrl = "https://voice."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
voice = mRetrofitBuilder
.baseUrl(baseUrl)
.build()
.create(IVoice.class);
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
/**
* Initiate phone call
* @param to Phone number to call
* @param from Number from which to initiate the call
* @return {@link com.africastalking.voice.CallResponse CallResponse}
* @throws IOException
*/
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/voice/src/main/java/com/africastalking/VoiceService.java
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.Response;
import java.io.IOException;
}
@Override
protected boolean isInitialized() {
return sInstance != null;
}
@Override
protected void initService() {
String baseUrl = "https://voice."+ (isSandbox ? Const.SANDBOX_DOMAIN : Const.PRODUCTION_DOMAIN) + "/";
voice = mRetrofitBuilder
.baseUrl(baseUrl)
.build()
.create(IVoice.class);
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
/**
* Initiate phone call
* @param to Phone number to call
* @param from Number from which to initiate the call
* @return {@link com.africastalking.voice.CallResponse CallResponse}
* @throws IOException
*/
|
public CallResponse call(String to, String from) throws IOException {
|
aksalj/africastalking-java
|
libs/voice/src/main/java/com/africastalking/VoiceService.java
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.Response;
import java.io.IOException;
|
}
/**
* Initiate phone call
* @param to Phone number to call
* @param from Number from which to initiate the call
* @param callback {@link com.africastalking.Callback Callback}
*/
public void call(String to, String from, final Callback<CallResponse> callback) {
try {
checkPhoneNumber(to);
Call<CallResponse> call = voice.call(mUsername, to, from);
call.enqueue(makeCallback(callback));
} catch (IOException ex){
callback.onFailure(ex);
}
}
public void call(String to, Callback<CallResponse> callback) {
call(to, "", callback);
}
/**
* Fetch queued calls
* @param phoneNumber Your virtual phone number
* @return {@link com.africastalking.voice.QueuedCallsResponse QueuedCallsResponse}
* @throws IOException
*/
|
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/voice/src/main/java/com/africastalking/VoiceService.java
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import retrofit2.Call;
import retrofit2.Response;
import java.io.IOException;
}
/**
* Initiate phone call
* @param to Phone number to call
* @param from Number from which to initiate the call
* @param callback {@link com.africastalking.Callback Callback}
*/
public void call(String to, String from, final Callback<CallResponse> callback) {
try {
checkPhoneNumber(to);
Call<CallResponse> call = voice.call(mUsername, to, from);
call.enqueue(makeCallback(callback));
} catch (IOException ex){
callback.onFailure(ex);
}
}
public void call(String to, Callback<CallResponse> callback) {
call(to, "", callback);
}
/**
* Fetch queued calls
* @param phoneNumber Your virtual phone number
* @return {@link com.africastalking.voice.QueuedCallsResponse QueuedCallsResponse}
* @throws IOException
*/
|
public QueuedCallsResponse fetchQueuedCalls(String phoneNumber) throws IOException {
|
aksalj/africastalking-java
|
example/src/main/java/com/africastalking/example/App.java
|
// Path: libs/payment/src/main/java/com/africastalking/payment/recipient/Consumer.java
// public final class Consumer {
//
// /*
// * Payment Reasons
// */
// public static final String REASON_SALARY = "SalaryPayment";
// public static final String REASON_SALARY_WITH_CHARGE = "SalaryPaymentWithWithdrawalChargePaid";
// public static final String REASON_BUSINESS = "BusinessPayment";
// public static final String REASON_BUSINESS_WITH_CHARGE = "BusinessPaymentWithWithdrawalChargePaid";
// public static final String REASON_PROMOTION = "PromotionPayment";
//
// public String name;
// public String phoneNumber;
// public String currencyCode;
// public float amount;
// public String providerChannel;
//
// public String reason;
// public HashMap<String, String> metadata = new HashMap<>();
//
// /**
// * Consumer-type payment recipient, used in B2C transactions
// * @param name Consumer name
// * @param phoneNumber Consumer phone number
// * @param amount Amount to transact, along with the currency code. e.g. KES 345
// * @param reason Purpose for the payment. e.g. {@link com.africastalking.payment.recipient.Consumer Consumer.REASON_SALARY}
// */
// public Consumer(String name, String phoneNumber, String amount, String reason) {
// this.name = name;
// this.phoneNumber = phoneNumber;
// this.reason = reason;
//
// try {
// String[] currenciedAmount = amount.trim().split(" ");
// this.currencyCode = currenciedAmount[0];
// this.amount = Float.parseFloat(currenciedAmount[1]);
// } catch (Exception ex) {
// throw new RuntimeException(ex);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
|
import com.africastalking.*;
import com.africastalking.payment.recipient.Consumer;
import com.africastalking.voice.action.*;
import com.google.gson.Gson;
import java.io.IOException;
import java.net.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import spark.ModelAndView;
import spark.template.handlebars.HandlebarsTemplateEngine;
import static spark.Spark.exception;
import static spark.Spark.get;
import static spark.Spark.port;
import static spark.Spark.post;
import static spark.Spark.staticFiles;
|
log(String.format("HTTP Server: %s:%d", host.getHostAddress(), HTTP_PORT));
log("\n");
HashMap<String, String> states = new HashMap<>();
String baseUrl = "http://aksalj.ngrok.io";
String songUrl = "https://upload.wikimedia.org/wikipedia/commons/transcoded/4/49/National_Anthem_of_Kenya.ogg/National_Anthem_of_Kenya.ogg.mp3";
setupAfricastalking();
port(HTTP_PORT);
staticFiles.location("/public");
exception(Exception.class, (e, req, res) -> e.printStackTrace()); // print all exceptions
get("/", (req, res) -> {
Map<String, Object> data = new HashMap<>();
data.put("req", req.pathInfo());
return render("index", data);
});
// Send SMS
post("/auth/register/:phone", (req, res) -> sms.send("Welcome to Awesome Company", "AT2FA", new String[] {req.params("phone")}, false), gson::toJson);
// Send Airtime
post("/airtime/:phone", (req, res) -> airtime.send(req.params("phone"), req.queryParams("amount")), gson::toJson);
// Mobile Checkout
post("/mobile/checkout/:phone", (req, res) -> payment.mobileCheckout("TestProduct", req.params("phone"), req.queryParams("amount"), null), gson::toJson);
// Mobile B2C
|
// Path: libs/payment/src/main/java/com/africastalking/payment/recipient/Consumer.java
// public final class Consumer {
//
// /*
// * Payment Reasons
// */
// public static final String REASON_SALARY = "SalaryPayment";
// public static final String REASON_SALARY_WITH_CHARGE = "SalaryPaymentWithWithdrawalChargePaid";
// public static final String REASON_BUSINESS = "BusinessPayment";
// public static final String REASON_BUSINESS_WITH_CHARGE = "BusinessPaymentWithWithdrawalChargePaid";
// public static final String REASON_PROMOTION = "PromotionPayment";
//
// public String name;
// public String phoneNumber;
// public String currencyCode;
// public float amount;
// public String providerChannel;
//
// public String reason;
// public HashMap<String, String> metadata = new HashMap<>();
//
// /**
// * Consumer-type payment recipient, used in B2C transactions
// * @param name Consumer name
// * @param phoneNumber Consumer phone number
// * @param amount Amount to transact, along with the currency code. e.g. KES 345
// * @param reason Purpose for the payment. e.g. {@link com.africastalking.payment.recipient.Consumer Consumer.REASON_SALARY}
// */
// public Consumer(String name, String phoneNumber, String amount, String reason) {
// this.name = name;
// this.phoneNumber = phoneNumber;
// this.reason = reason;
//
// try {
// String[] currenciedAmount = amount.trim().split(" ");
// this.currencyCode = currenciedAmount[0];
// this.amount = Float.parseFloat(currenciedAmount[1]);
// } catch (Exception ex) {
// throw new RuntimeException(ex);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
// Path: example/src/main/java/com/africastalking/example/App.java
import com.africastalking.*;
import com.africastalking.payment.recipient.Consumer;
import com.africastalking.voice.action.*;
import com.google.gson.Gson;
import java.io.IOException;
import java.net.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import spark.ModelAndView;
import spark.template.handlebars.HandlebarsTemplateEngine;
import static spark.Spark.exception;
import static spark.Spark.get;
import static spark.Spark.port;
import static spark.Spark.post;
import static spark.Spark.staticFiles;
log(String.format("HTTP Server: %s:%d", host.getHostAddress(), HTTP_PORT));
log("\n");
HashMap<String, String> states = new HashMap<>();
String baseUrl = "http://aksalj.ngrok.io";
String songUrl = "https://upload.wikimedia.org/wikipedia/commons/transcoded/4/49/National_Anthem_of_Kenya.ogg/National_Anthem_of_Kenya.ogg.mp3";
setupAfricastalking();
port(HTTP_PORT);
staticFiles.location("/public");
exception(Exception.class, (e, req, res) -> e.printStackTrace()); // print all exceptions
get("/", (req, res) -> {
Map<String, Object> data = new HashMap<>();
data.put("req", req.pathInfo());
return render("index", data);
});
// Send SMS
post("/auth/register/:phone", (req, res) -> sms.send("Welcome to Awesome Company", "AT2FA", new String[] {req.params("phone")}, false), gson::toJson);
// Send Airtime
post("/airtime/:phone", (req, res) -> airtime.send(req.params("phone"), req.queryParams("amount")), gson::toJson);
// Mobile Checkout
post("/mobile/checkout/:phone", (req, res) -> payment.mobileCheckout("TestProduct", req.params("phone"), req.queryParams("amount"), null), gson::toJson);
// Mobile B2C
|
post("/mobile/b2c/:phone", (req, res) -> payment.mobileB2C("TestProduct", Arrays.asList(new Consumer("Boby", req.params("phone"), req.queryParams("amount"), Consumer.REASON_SALARY))), gson::toJson);
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
|
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
|
package com.africastalking.test.voice;
public class VoiceTest {
@Before
public void setup() {
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
// Path: libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
package com.africastalking.test.voice;
public class VoiceTest {
@Before
public void setup() {
|
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
|
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
|
package com.africastalking.test.voice;
public class VoiceTest {
@Before
public void setup() {
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
}
@Test
public void testCall() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
// Path: libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
package com.africastalking.test.voice;
public class VoiceTest {
@Before
public void setup() {
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
}
@Test
public void testCall() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
|
final CallResponse response = service.call("+254718769882", "0718769881");
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
|
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
|
package com.africastalking.test.voice;
public class VoiceTest {
@Before
public void setup() {
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
}
@Test
public void testCall() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final CallResponse response = service.call("+254718769882", "0718769881");
Assert.assertEquals("Invalid callerId: 0718769881", response.errorMessage);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testFetchQueuedCalls() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
// Path: libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
package com.africastalking.test.voice;
public class VoiceTest {
@Before
public void setup() {
AfricasTalking.initialize(Fixtures.USERNAME, Fixtures.API_KEY);
}
@Test
public void testCall() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final CallResponse response = service.call("+254718769882", "0718769881");
Assert.assertEquals("Invalid callerId: 0718769881", response.errorMessage);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testFetchQueuedCalls() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
|
final QueuedCallsResponse response = service.fetchQueuedCalls("0718769882");
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
|
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
|
}
@Test
public void testFetchQueuedCalls() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final QueuedCallsResponse response = service.fetchQueuedCalls("0718769882");
Assert.assertEquals(0, response.numCalls);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testUploadMediaFile() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final String response = service.uploadMediaFile("+254718769889", "http://defef.klo/wave.mp3");
Assert.assertNotNull(response);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testXmlBuilder() {
ActionBuilder builder = new ActionBuilder();
String say = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Say voice=\"man\">Your balance is 1234 Shillings</Say></Response>";
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
// Path: libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
}
@Test
public void testFetchQueuedCalls() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final QueuedCallsResponse response = service.fetchQueuedCalls("0718769882");
Assert.assertEquals(0, response.numCalls);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testUploadMediaFile() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final String response = service.uploadMediaFile("+254718769889", "http://defef.klo/wave.mp3");
Assert.assertNotNull(response);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testXmlBuilder() {
ActionBuilder builder = new ActionBuilder();
String say = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Say voice=\"man\">Your balance is 1234 Shillings</Say></Response>";
|
Assert.assertEquals(say, builder.say(new Say("Your balance is 1234 Shillings", false, Say.Voice.MAN)).build());
|
aksalj/africastalking-java
|
libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
|
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
|
}
@Test
public void testUploadMediaFile() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final String response = service.uploadMediaFile("+254718769889", "http://defef.klo/wave.mp3");
Assert.assertNotNull(response);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testXmlBuilder() {
ActionBuilder builder = new ActionBuilder();
String say = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Say voice=\"man\">Your balance is 1234 Shillings</Say></Response>";
Assert.assertEquals(say, builder.say(new Say("Your balance is 1234 Shillings", false, Say.Voice.MAN)).build());
builder = new ActionBuilder();
String getDigits = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Response>" +
"<GetDigits finishOnKey=\"#\">" +
"<Say>Please enter your account number followed by the hash sign</Say>" +
"</GetDigits>" +
"<Record/>" +
"</Response>";
String getDigitsTest = builder
|
// Path: libs/core/src/test/java/com/africastalking/test/Fixtures.java
// public final class Fixtures {
// public static String API_KEY;
// public static String USERNAME;
// public static final boolean DEBUG = true;
// public static final long TIMEOUT = 3500;
//
// static {
// try {
// String filePath = "../../local.properties"; // relative to libs/core
// Properties properties = new Properties();
// FileInputStream is = new FileInputStream(filePath);
// properties.load(is);
// API_KEY = properties.getProperty("api.key");
// USERNAME = properties.getProperty("api.username");
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/CallResponse.java
// public final class CallResponse {
// public String status;
// public String phoneNumber;
// public String errorMessage;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/QueuedCallsResponse.java
// public final class QueuedCallsResponse {
// public String phoneNumber;
// public String queueName;
// public int numCalls;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/GetDigits.java
// public class GetDigits extends Action {
//
// /**
// * Get Digits
// * @param say
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Say say, int numDigits, String finishOnKey, URL callbackUrl) {
// init(say, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Say say) {
// init(say, 0, null, null);
// }
//
//
// /**
// * Get Digits
// * @param play
// * @param numDigits
// * @param finishOnKey
// * @param callbackUrl
// */
// public GetDigits(Play play, int numDigits, String finishOnKey, URL callbackUrl) {
// init(play, numDigits, finishOnKey, callbackUrl);
// }
//
// public GetDigits(Play play) {
// init(play, 0, null, null);
// }
//
// private void init(Action child, int numDigits, String finishOnKey, URL callbackUrl) {
// this.tag = "GetDigits";
//
// if (numDigits > 0) {
// this.attributes.put("numDigits", String.valueOf(numDigits));
// }
//
// if (finishOnKey != null) {
// this.attributes.put("finishOnKey", finishOnKey);
// }
//
// if (callbackUrl != null) {
// this.attributes.put("callbackUrl", callbackUrl.toString());
// }
//
// this.children.add(child);
// }
// }
//
// Path: libs/voice/src/main/java/com/africastalking/voice/action/Say.java
// public class Say extends Action {
//
// public enum Voice { MAN, WOMAN }
//
// /**
// * Say
// * @param text
// * @param playBeep
// * @param voice
// */
// public Say(String text, boolean playBeep, Voice voice) {
// this.tag = "Say";
// this.text = text;
//
// if (playBeep) {
// this.attributes.put("playBeep", "true");
// }
//
// if (voice != null) {
// this.attributes.put("voice", voice.name().toLowerCase());
// }
// }
//
// public Say(String text) {
// this(text, false, null);
// }
//
// public Say(String text, Voice voice) {
// this(text, false, voice);
// }
//
// public Say(String text, boolean playBeep) {
// this(text, playBeep, null);
// }
//
// }
// Path: libs/core/src/test/java/com/africastalking/test/voice/VoiceTest.java
import com.africastalking.*;
import com.africastalking.test.Fixtures;
import com.africastalking.voice.CallResponse;
import com.africastalking.voice.QueuedCallsResponse;
import com.africastalking.voice.action.GetDigits;
import com.africastalking.voice.action.Record;
import com.africastalking.voice.action.Say;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import static org.junit.Assert.assertEquals;
}
@Test
public void testUploadMediaFile() {
VoiceService service = AfricasTalking.getService(VoiceService.class);
try {
final String response = service.uploadMediaFile("+254718769889", "http://defef.klo/wave.mp3");
Assert.assertNotNull(response);
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
@Test
public void testXmlBuilder() {
ActionBuilder builder = new ActionBuilder();
String say = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Say voice=\"man\">Your balance is 1234 Shillings</Say></Response>";
Assert.assertEquals(say, builder.say(new Say("Your balance is 1234 Shillings", false, Say.Voice.MAN)).build());
builder = new ActionBuilder();
String getDigits = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Response>" +
"<GetDigits finishOnKey=\"#\">" +
"<Say>Please enter your account number followed by the hash sign</Say>" +
"</GetDigits>" +
"<Record/>" +
"</Response>";
String getDigitsTest = builder
|
.getDigits(new GetDigits(
|
aksalj/africastalking-java
|
libs/account/src/main/java/com/africastalking/AccountService.java
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.account.AccountResponse;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
|
Retrofit retrofit = mRetrofitBuilder
.baseUrl(url)
.build();
service = retrofit.create(IAccount.class);
}
@Override
protected boolean isInitialized() {
return sInstance != null;
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
// ->
/**
* Get user info.
* <p>
* Synchronously send the request and return its response.
* </p>
* @return String in specified format, xml or json
* @throws IOException
*/
|
// Path: libs/account/src/main/java/com/africastalking/account/AccountResponse.java
// public final class AccountResponse {
//
// @SerializedName("UserData")
// public UserData userData;
//
// public static final class UserData {
// public String balance;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/account/src/main/java/com/africastalking/AccountService.java
import com.africastalking.account.AccountResponse;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import java.io.IOException;
Retrofit retrofit = mRetrofitBuilder
.baseUrl(url)
.build();
service = retrofit.create(IAccount.class);
}
@Override
protected boolean isInitialized() {
return sInstance != null;
}
@Override
protected void destroyService() {
if (sInstance != null) {
sInstance = null;
}
}
// ->
/**
* Get user info.
* <p>
* Synchronously send the request and return its response.
* </p>
* @return String in specified format, xml or json
* @throws IOException
*/
|
public AccountResponse fetchAccount() throws IOException {
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
if (recipients == null){
return null;
}
if (recipients.length == 1) {
return recipients[0];
}
StringJoiner joiner = new StringJoiner(",");
for (CharSequence cs: recipients) {
checkPhoneNumber(cs.toString());
joiner.add(cs);
}
return joiner.toString();
}
// -> Bulk
/**
* Send a message
* <p>
* Synchronously send the request and return its response.
* </p>
* @param message
* @param from
* @param recipients
* @param enqueue
* @return
* @throws IOException
*/
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
if (recipients == null){
return null;
}
if (recipients.length == 1) {
return recipients[0];
}
StringJoiner joiner = new StringJoiner(",");
for (CharSequence cs: recipients) {
checkPhoneNumber(cs.toString());
joiner.add(cs);
}
return joiner.toString();
}
// -> Bulk
/**
* Send a message
* <p>
* Synchronously send the request and return its response.
* </p>
* @param message
* @param from
* @param recipients
* @param enqueue
* @return
* @throws IOException
*/
|
public List<Recipient> send(String message, String from, String[] recipients, boolean enqueue) throws IOException {
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
return null;
}
if (recipients.length == 1) {
return recipients[0];
}
StringJoiner joiner = new StringJoiner(",");
for (CharSequence cs: recipients) {
checkPhoneNumber(cs.toString());
joiner.add(cs);
}
return joiner.toString();
}
// -> Bulk
/**
* Send a message
* <p>
* Synchronously send the request and return its response.
* </p>
* @param message
* @param from
* @param recipients
* @param enqueue
* @return
* @throws IOException
*/
public List<Recipient> send(String message, String from, String[] recipients, boolean enqueue) throws IOException {
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
return null;
}
if (recipients.length == 1) {
return recipients[0];
}
StringJoiner joiner = new StringJoiner(",");
for (CharSequence cs: recipients) {
checkPhoneNumber(cs.toString());
joiner.add(cs);
}
return joiner.toString();
}
// -> Bulk
/**
* Send a message
* <p>
* Synchronously send the request and return its response.
* </p>
* @param message
* @param from
* @param recipients
* @param enqueue
* @return
* @throws IOException
*/
public List<Recipient> send(String message, String from, String[] recipients, boolean enqueue) throws IOException {
|
Response<SendMessageResponse> resp = sms.send(mUsername, formatRecipients(recipients), from, message, 1, enqueue ? "1" : null).execute();
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
return sendPremium(message, null, keyword, linkId, -1, recipients);
}
/**
* Send premium SMS
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param message
* @param keyword
* @param linkId
* @param recipients
* @param callback
*/
public void sendPremium(String message, String keyword, String linkId, String[] recipients, Callback<List<Recipient>> callback){
sendPremium(message, null, keyword, linkId, -1, recipients, callback);
}
// -> Fetch Message
/**
* Fetch messages
* <p>
* Synchronously send the request and return its response.
* </p>
* @param lastReceivedId
* @return
* @throws IOException
*/
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
return sendPremium(message, null, keyword, linkId, -1, recipients);
}
/**
* Send premium SMS
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param message
* @param keyword
* @param linkId
* @param recipients
* @param callback
*/
public void sendPremium(String message, String keyword, String linkId, String[] recipients, Callback<List<Recipient>> callback){
sendPremium(message, null, keyword, linkId, -1, recipients, callback);
}
// -> Fetch Message
/**
* Fetch messages
* <p>
* Synchronously send the request and return its response.
* </p>
* @param lastReceivedId
* @return
* @throws IOException
*/
|
public List<Message> fetchMessages(String lastReceivedId) throws IOException {
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
}
/**
* Send premium SMS
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param message
* @param keyword
* @param linkId
* @param recipients
* @param callback
*/
public void sendPremium(String message, String keyword, String linkId, String[] recipients, Callback<List<Recipient>> callback){
sendPremium(message, null, keyword, linkId, -1, recipients, callback);
}
// -> Fetch Message
/**
* Fetch messages
* <p>
* Synchronously send the request and return its response.
* </p>
* @param lastReceivedId
* @return
* @throws IOException
*/
public List<Message> fetchMessages(String lastReceivedId) throws IOException {
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
}
/**
* Send premium SMS
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param message
* @param keyword
* @param linkId
* @param recipients
* @param callback
*/
public void sendPremium(String message, String keyword, String linkId, String[] recipients, Callback<List<Recipient>> callback){
sendPremium(message, null, keyword, linkId, -1, recipients, callback);
}
// -> Fetch Message
/**
* Fetch messages
* <p>
* Synchronously send the request and return its response.
* </p>
* @param lastReceivedId
* @return
* @throws IOException
*/
public List<Message> fetchMessages(String lastReceivedId) throws IOException {
|
Response<FetchMessageResponse> resp = sms.fetchMessages(mUsername, lastReceivedId).execute();
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
callback.onFailure(throwable);
}
}));
}
/**
* Fetch messages
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param callback
*/
public void fetchMessages(Callback<List<Message>> callback) {
fetchMessages("0", callback);
}
// -> Fetch Subscription
/**
* Fetch subscriptions
* <p>
* Synchronously send the request and return its response.
* </p>
* @param shortCode
* @param keyword
* @param lastReceivedId
* @return
* @throws IOException
*/
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
callback.onFailure(throwable);
}
}));
}
/**
* Fetch messages
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param callback
*/
public void fetchMessages(Callback<List<Message>> callback) {
fetchMessages("0", callback);
}
// -> Fetch Subscription
/**
* Fetch subscriptions
* <p>
* Synchronously send the request and return its response.
* </p>
* @param shortCode
* @param keyword
* @param lastReceivedId
* @return
* @throws IOException
*/
|
public List<Subscription> fetchSubscriptions(String shortCode, String keyword, String lastReceivedId) throws IOException {
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
}
}));
}
/**
* Fetch messages
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param callback
*/
public void fetchMessages(Callback<List<Message>> callback) {
fetchMessages("0", callback);
}
// -> Fetch Subscription
/**
* Fetch subscriptions
* <p>
* Synchronously send the request and return its response.
* </p>
* @param shortCode
* @param keyword
* @param lastReceivedId
* @return
* @throws IOException
*/
public List<Subscription> fetchSubscriptions(String shortCode, String keyword, String lastReceivedId) throws IOException {
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
}
}));
}
/**
* Fetch messages
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param callback
*/
public void fetchMessages(Callback<List<Message>> callback) {
fetchMessages("0", callback);
}
// -> Fetch Subscription
/**
* Fetch subscriptions
* <p>
* Synchronously send the request and return its response.
* </p>
* @param shortCode
* @param keyword
* @param lastReceivedId
* @return
* @throws IOException
*/
public List<Subscription> fetchSubscriptions(String shortCode, String keyword, String lastReceivedId) throws IOException {
|
Response<FetchSubscriptionResponse> resp = sms.fetchSubscriptions(mUsername, shortCode, keyword, lastReceivedId).execute();
|
aksalj/africastalking-java
|
libs/sms/src/main/java/com/africastalking/SmsService.java
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
|
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
|
/**
* Create subscription
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param shortCode
* @param keyword
* @param callback
*/
public void fetchSubscriptions(String shortCode, String keyword, Callback<List<Subscription>> callback) {
fetchSubscriptions(shortCode, keyword, "0", callback);
}
// -> Create subscription
/**
* Create subscription
* <p>
* Synchronously send the request and return its response.
* </p>
* @param shortCode
* @param keyword
* @param phoneNumber
* @param checkoutToken
* @return
* @throws IOException
*/
|
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchMessageResponse.java
// public final class FetchMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Message> messages = new ArrayList<>();
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/FetchSubscriptionResponse.java
// public final class FetchSubscriptionResponse {
// @SerializedName("Subscriptions")
// public List<Subscription> subscriptions = new ArrayList<>();
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Message.java
// public final class Message {
// public String from;
// public String to;
// public String text;
// public String linkId;
// public String date;
// public long id;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Recipient.java
// public final class Recipient {
// public String number;
// public String cost;
// public String status;
// public String messageId;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SendMessageResponse.java
// public final class SendMessageResponse {
//
// @SerializedName("SMSMessageData")
// public SmsMessageData data;
//
// public static final class SmsMessageData {
// @SerializedName("Recipients")
// public List<Recipient> recipients;
// }
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
//
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/Subscription.java
// public final class Subscription {
// public long id;
// public String phoneNumber;
// public String date;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
//
// Path: libs/sms/src/main/java/com/africastalking/sms/SubscriptionResponse.java
// public final class SubscriptionResponse {
// public String success;
// public String description;
//
// @Override
// public String toString() {
// return new Gson().toJson(this);
// }
// }
// Path: libs/sms/src/main/java/com/africastalking/SmsService.java
import com.africastalking.sms.FetchMessageResponse;
import com.africastalking.sms.FetchSubscriptionResponse;
import com.africastalking.sms.Message;
import com.africastalking.sms.Recipient;
import com.africastalking.sms.SendMessageResponse;
import com.africastalking.sms.Subscription;
import com.africastalking.sms.SubscriptionResponse;
import retrofit2.Response;
import java.io.IOException;
import java.util.List;
import java.util.StringJoiner;
/**
* Create subscription
* <p>
* Asynchronously send the request and notify {@code callback} of its response or if an error
* occurred
* </p>
* @param shortCode
* @param keyword
* @param callback
*/
public void fetchSubscriptions(String shortCode, String keyword, Callback<List<Subscription>> callback) {
fetchSubscriptions(shortCode, keyword, "0", callback);
}
// -> Create subscription
/**
* Create subscription
* <p>
* Synchronously send the request and return its response.
* </p>
* @param shortCode
* @param keyword
* @param phoneNumber
* @param checkoutToken
* @return
* @throws IOException
*/
|
public SubscriptionResponse createSubscription(String shortCode, String keyword, String phoneNumber, String checkoutToken) throws IOException {
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/config/DateParamModelConvertorProvider.java
|
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
|
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.ParamConverterProvider;
import javax.ws.rs.ext.Provider;
import org.geekmj.model.DateParamModel;
|
package org.geekmj.config;
@Provider
public class DateParamModelConvertorProvider implements ParamConverterProvider {
@Override
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
|
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
// Path: src/main/java/org/geekmj/config/DateParamModelConvertorProvider.java
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import javax.ws.rs.ext.ParamConverter;
import javax.ws.rs.ext.ParamConverterProvider;
import javax.ws.rs.ext.Provider;
import org.geekmj.model.DateParamModel;
package org.geekmj.config;
@Provider
public class DateParamModelConvertorProvider implements ParamConverterProvider {
@Override
public <T> ParamConverter<T> getConverter(Class<T> rawType, Type genericType, Annotation[] annotations) {
|
if (rawType.getName().equals(DateParamModel.class.getName())) {
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/resource/BeanParamResource.java
|
// Path: src/main/java/org/geekmj/model/BeanParamModel.java
// public class BeanParamModel {
//
// @HeaderParam(value = "header-value")
// private String headerValue;
//
// @CookieParam(value = "cookie-value")
// private String cookieValue;
//
// private String pathValue;
//
// private String param1;
//
// public BeanParamModel(@PathParam("path-value") @Optional String pathValue,
// @QueryParam("param1") @Optional String param1) {
// this.pathValue = pathValue;
// this.param1 = param1;
// }
//
// public String getHeaderValue() {
// return headerValue;
// }
//
// public void setHeaderValue(String headerValue) {
// this.headerValue = headerValue;
// }
//
// public String getCookieValue() {
// return cookieValue;
// }
//
// public void setCookieValue(String cookieValue) {
// this.cookieValue = cookieValue;
// }
//
// public String getPathValue() {
// return pathValue;
// }
//
// public void setPathValue(String pathValue) {
// this.pathValue = pathValue;
// }
//
// public String getParam1() {
// return param1;
// }
//
// public void setParam1(String param1) {
// this.param1 = param1;
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.GET;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.geekmj.model.BeanParamModel;
import org.springframework.stereotype.Component;
|
package org.geekmj.resource;
@Path("/bean-param")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class BeanParamResource {
@GET
@Path("{path-value}")
|
// Path: src/main/java/org/geekmj/model/BeanParamModel.java
// public class BeanParamModel {
//
// @HeaderParam(value = "header-value")
// private String headerValue;
//
// @CookieParam(value = "cookie-value")
// private String cookieValue;
//
// private String pathValue;
//
// private String param1;
//
// public BeanParamModel(@PathParam("path-value") @Optional String pathValue,
// @QueryParam("param1") @Optional String param1) {
// this.pathValue = pathValue;
// this.param1 = param1;
// }
//
// public String getHeaderValue() {
// return headerValue;
// }
//
// public void setHeaderValue(String headerValue) {
// this.headerValue = headerValue;
// }
//
// public String getCookieValue() {
// return cookieValue;
// }
//
// public void setCookieValue(String cookieValue) {
// this.cookieValue = cookieValue;
// }
//
// public String getPathValue() {
// return pathValue;
// }
//
// public void setPathValue(String pathValue) {
// this.pathValue = pathValue;
// }
//
// public String getParam1() {
// return param1;
// }
//
// public void setParam1(String param1) {
// this.param1 = param1;
// }
//
// }
// Path: src/main/java/org/geekmj/resource/BeanParamResource.java
import java.util.HashMap;
import java.util.Map;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.GET;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.geekmj.model.BeanParamModel;
import org.springframework.stereotype.Component;
package org.geekmj.resource;
@Path("/bean-param")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class BeanParamResource {
@GET
@Path("{path-value}")
|
public Response getResponse(@BeanParam BeanParamModel beanParam) {
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/resource/EmployeeResource.java
|
// Path: src/main/java/org/geekmj/domain/Employee.java
// public class Employee {
// private int id;
// private String name;
// private String address;
// private Date createdOn;
// private Date modifiedOn;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public Date getCreatedOn() {
// return createdOn;
// }
//
// public void setCreatedOn(Date createdOn) {
// this.createdOn = createdOn;
// }
//
// public Date getModifiedOn() {
// return modifiedOn;
// }
//
// public void setModifiedOn(Date modifiedOn) {
// this.modifiedOn = modifiedOn;
// }
//
// }
|
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.geekmj.domain.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
package org.geekmj.resource;
@Path("/employees")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class EmployeeResource {
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Autowired
public EmployeeResource(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
}
@POST
|
// Path: src/main/java/org/geekmj/domain/Employee.java
// public class Employee {
// private int id;
// private String name;
// private String address;
// private Date createdOn;
// private Date modifiedOn;
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getAddress() {
// return address;
// }
//
// public void setAddress(String address) {
// this.address = address;
// }
//
// public Date getCreatedOn() {
// return createdOn;
// }
//
// public void setCreatedOn(Date createdOn) {
// this.createdOn = createdOn;
// }
//
// public Date getModifiedOn() {
// return modifiedOn;
// }
//
// public void setModifiedOn(Date modifiedOn) {
// this.modifiedOn = modifiedOn;
// }
//
// }
// Path: src/main/java/org/geekmj/resource/EmployeeResource.java
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.geekmj.domain.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
package org.geekmj.resource;
@Path("/employees")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class EmployeeResource {
private final NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Autowired
public EmployeeResource(NamedParameterJdbcTemplate namedParameterJdbcTemplate) {
this.namedParameterJdbcTemplate = namedParameterJdbcTemplate;
}
@POST
|
public String createEmployee(final Employee employee) {
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/resource/JsonPayloadResource.java
|
// Path: src/main/java/org/geekmj/domain/Movie.java
// public class Movie {
// private Long id;
// private String title;
// private Integer releaseYear;
// private Float imdbRating;
// private List<Actor> actors;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public Integer getReleaseYear() {
// return releaseYear;
// }
//
// public void setReleaseYear(Integer releaseYear) {
// this.releaseYear = releaseYear;
// }
//
// public Float getImdbRating() {
// return imdbRating;
// }
//
// public void setImdbRating(Float imdbRating) {
// this.imdbRating = imdbRating;
// }
//
// public List<Actor> getActors() {
// return actors;
// }
//
// public void setActors(List<Actor> actors) {
// this.actors = actors;
// }
//
// }
|
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.geekmj.domain.Movie;
|
package org.geekmj.resource;
@Path("/json-payload")
public class JsonPayloadResource {
/**
* This Resource method takes HTTP entity pay-load in JSON format.
* This Resource method gives back HTTP entity pay-load in JSON format.
* Jackson is the default JSON Entity provider for Spring Boot + Jersey application.
* It convert JSON in the pay-load to Java Object.
* It also convert Java Object to JSON.
*/
@POST
@Path("/movie")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
|
// Path: src/main/java/org/geekmj/domain/Movie.java
// public class Movie {
// private Long id;
// private String title;
// private Integer releaseYear;
// private Float imdbRating;
// private List<Actor> actors;
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public String getTitle() {
// return title;
// }
//
// public void setTitle(String title) {
// this.title = title;
// }
//
// public Integer getReleaseYear() {
// return releaseYear;
// }
//
// public void setReleaseYear(Integer releaseYear) {
// this.releaseYear = releaseYear;
// }
//
// public Float getImdbRating() {
// return imdbRating;
// }
//
// public void setImdbRating(Float imdbRating) {
// this.imdbRating = imdbRating;
// }
//
// public List<Actor> getActors() {
// return actors;
// }
//
// public void setActors(List<Actor> actors) {
// this.actors = actors;
// }
//
// }
// Path: src/main/java/org/geekmj/resource/JsonPayloadResource.java
import javax.ws.rs.Consumes;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.geekmj.domain.Movie;
package org.geekmj.resource;
@Path("/json-payload")
public class JsonPayloadResource {
/**
* This Resource method takes HTTP entity pay-load in JSON format.
* This Resource method gives back HTTP entity pay-load in JSON format.
* Jackson is the default JSON Entity provider for Spring Boot + Jersey application.
* It convert JSON in the pay-load to Java Object.
* It also convert Java Object to JSON.
*/
@POST
@Path("/movie")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
|
public Movie takeAndGiveMovie(final Movie movie) {
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/resource/CustomTypeParamterConsumeResource.java
|
// Path: src/main/java/org/geekmj/model/ConstructorDateParamModel.java
// public class ConstructorDateParamModel {
//
// private String dateAsString;
//
// /* Expecting ISO-8601 format date string */
// public ConstructorDateParamModel(String dateAsString) {
// this.dateAsString = dateAsString;
//
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/StaticMethodDateParamModel.java
// public class StaticMethodDateParamModel {
//
// private String dateAsString;
//
// public StaticMethodDateParamModel() {
// }
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// /*
// * Expecting ISO-8601 format date string
// *
// */
// public static StaticMethodDateParamModel valueOf(String dateAsString) {
// StaticMethodDateParamModel staticMethodDateParamModel = new StaticMethodDateParamModel();
// staticMethodDateParamModel.setDateAsString(dateAsString);
// return staticMethodDateParamModel;
// }
//
// }
|
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.geekmj.model.ConstructorDateParamModel;
import org.geekmj.model.DateParamModel;
import org.geekmj.model.StaticMethodDateParamModel;
import org.springframework.stereotype.Component;
|
package org.geekmj.resource;
@Path("/custom-type-for-parameters")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class CustomTypeParamterConsumeResource {
@QueryParam("datesAsStrings")
|
// Path: src/main/java/org/geekmj/model/ConstructorDateParamModel.java
// public class ConstructorDateParamModel {
//
// private String dateAsString;
//
// /* Expecting ISO-8601 format date string */
// public ConstructorDateParamModel(String dateAsString) {
// this.dateAsString = dateAsString;
//
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/StaticMethodDateParamModel.java
// public class StaticMethodDateParamModel {
//
// private String dateAsString;
//
// public StaticMethodDateParamModel() {
// }
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// /*
// * Expecting ISO-8601 format date string
// *
// */
// public static StaticMethodDateParamModel valueOf(String dateAsString) {
// StaticMethodDateParamModel staticMethodDateParamModel = new StaticMethodDateParamModel();
// staticMethodDateParamModel.setDateAsString(dateAsString);
// return staticMethodDateParamModel;
// }
//
// }
// Path: src/main/java/org/geekmj/resource/CustomTypeParamterConsumeResource.java
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.geekmj.model.ConstructorDateParamModel;
import org.geekmj.model.DateParamModel;
import org.geekmj.model.StaticMethodDateParamModel;
import org.springframework.stereotype.Component;
package org.geekmj.resource;
@Path("/custom-type-for-parameters")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class CustomTypeParamterConsumeResource {
@QueryParam("datesAsStrings")
|
private List<DateParamModel> dateParamModels;
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/resource/CustomTypeParamterConsumeResource.java
|
// Path: src/main/java/org/geekmj/model/ConstructorDateParamModel.java
// public class ConstructorDateParamModel {
//
// private String dateAsString;
//
// /* Expecting ISO-8601 format date string */
// public ConstructorDateParamModel(String dateAsString) {
// this.dateAsString = dateAsString;
//
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/StaticMethodDateParamModel.java
// public class StaticMethodDateParamModel {
//
// private String dateAsString;
//
// public StaticMethodDateParamModel() {
// }
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// /*
// * Expecting ISO-8601 format date string
// *
// */
// public static StaticMethodDateParamModel valueOf(String dateAsString) {
// StaticMethodDateParamModel staticMethodDateParamModel = new StaticMethodDateParamModel();
// staticMethodDateParamModel.setDateAsString(dateAsString);
// return staticMethodDateParamModel;
// }
//
// }
|
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.geekmj.model.ConstructorDateParamModel;
import org.geekmj.model.DateParamModel;
import org.geekmj.model.StaticMethodDateParamModel;
import org.springframework.stereotype.Component;
|
package org.geekmj.resource;
@Path("/custom-type-for-parameters")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class CustomTypeParamterConsumeResource {
@QueryParam("datesAsStrings")
private List<DateParamModel> dateParamModels;
@CookieParam("dateParamModelAsCookie")
|
// Path: src/main/java/org/geekmj/model/ConstructorDateParamModel.java
// public class ConstructorDateParamModel {
//
// private String dateAsString;
//
// /* Expecting ISO-8601 format date string */
// public ConstructorDateParamModel(String dateAsString) {
// this.dateAsString = dateAsString;
//
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/StaticMethodDateParamModel.java
// public class StaticMethodDateParamModel {
//
// private String dateAsString;
//
// public StaticMethodDateParamModel() {
// }
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// /*
// * Expecting ISO-8601 format date string
// *
// */
// public static StaticMethodDateParamModel valueOf(String dateAsString) {
// StaticMethodDateParamModel staticMethodDateParamModel = new StaticMethodDateParamModel();
// staticMethodDateParamModel.setDateAsString(dateAsString);
// return staticMethodDateParamModel;
// }
//
// }
// Path: src/main/java/org/geekmj/resource/CustomTypeParamterConsumeResource.java
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.geekmj.model.ConstructorDateParamModel;
import org.geekmj.model.DateParamModel;
import org.geekmj.model.StaticMethodDateParamModel;
import org.springframework.stereotype.Component;
package org.geekmj.resource;
@Path("/custom-type-for-parameters")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class CustomTypeParamterConsumeResource {
@QueryParam("datesAsStrings")
private List<DateParamModel> dateParamModels;
@CookieParam("dateParamModelAsCookie")
|
private StaticMethodDateParamModel cookieDateParamModel;
|
geekmj/jersey-jax-rs-examples
|
src/main/java/org/geekmj/resource/CustomTypeParamterConsumeResource.java
|
// Path: src/main/java/org/geekmj/model/ConstructorDateParamModel.java
// public class ConstructorDateParamModel {
//
// private String dateAsString;
//
// /* Expecting ISO-8601 format date string */
// public ConstructorDateParamModel(String dateAsString) {
// this.dateAsString = dateAsString;
//
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/StaticMethodDateParamModel.java
// public class StaticMethodDateParamModel {
//
// private String dateAsString;
//
// public StaticMethodDateParamModel() {
// }
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// /*
// * Expecting ISO-8601 format date string
// *
// */
// public static StaticMethodDateParamModel valueOf(String dateAsString) {
// StaticMethodDateParamModel staticMethodDateParamModel = new StaticMethodDateParamModel();
// staticMethodDateParamModel.setDateAsString(dateAsString);
// return staticMethodDateParamModel;
// }
//
// }
|
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.geekmj.model.ConstructorDateParamModel;
import org.geekmj.model.DateParamModel;
import org.geekmj.model.StaticMethodDateParamModel;
import org.springframework.stereotype.Component;
|
package org.geekmj.resource;
@Path("/custom-type-for-parameters")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class CustomTypeParamterConsumeResource {
@QueryParam("datesAsStrings")
private List<DateParamModel> dateParamModels;
@CookieParam("dateParamModelAsCookie")
private StaticMethodDateParamModel cookieDateParamModel;
@HeaderParam("dateParamModelAsHeader")
|
// Path: src/main/java/org/geekmj/model/ConstructorDateParamModel.java
// public class ConstructorDateParamModel {
//
// private String dateAsString;
//
// /* Expecting ISO-8601 format date string */
// public ConstructorDateParamModel(String dateAsString) {
// this.dateAsString = dateAsString;
//
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/DateParamModel.java
// public class DateParamModel {
//
// private String dateAsString;
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// }
//
// Path: src/main/java/org/geekmj/model/StaticMethodDateParamModel.java
// public class StaticMethodDateParamModel {
//
// private String dateAsString;
//
// public StaticMethodDateParamModel() {
// }
//
// public String getDateAsString() {
// return dateAsString;
// }
//
// public void setDateAsString(String dateAsString) {
// this.dateAsString = dateAsString;
// }
//
// public LocalDateTime getDate() {
// LocalDateTime dateTime = null;
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE_TIME);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date time failed.");
// }
// try {
// dateTime = LocalDateTime.parse(dateAsString, DateTimeFormatter.ISO_DATE);
// } catch (DateTimeParseException ex) {
// System.err.println("Conversion of dateAsString: " + dateAsString + " using ISO date failed.");
// }
//
// return dateTime;
// }
//
// /*
// * Expecting ISO-8601 format date string
// *
// */
// public static StaticMethodDateParamModel valueOf(String dateAsString) {
// StaticMethodDateParamModel staticMethodDateParamModel = new StaticMethodDateParamModel();
// staticMethodDateParamModel.setDateAsString(dateAsString);
// return staticMethodDateParamModel;
// }
//
// }
// Path: src/main/java/org/geekmj/resource/CustomTypeParamterConsumeResource.java
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.Consumes;
import javax.ws.rs.CookieParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.geekmj.model.ConstructorDateParamModel;
import org.geekmj.model.DateParamModel;
import org.geekmj.model.StaticMethodDateParamModel;
import org.springframework.stereotype.Component;
package org.geekmj.resource;
@Path("/custom-type-for-parameters")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Component
public class CustomTypeParamterConsumeResource {
@QueryParam("datesAsStrings")
private List<DateParamModel> dateParamModels;
@CookieParam("dateParamModelAsCookie")
private StaticMethodDateParamModel cookieDateParamModel;
@HeaderParam("dateParamModelAsHeader")
|
private ConstructorDateParamModel headerDateParamModel;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/SawFunction.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class SawFunction implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/SawFunction.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class SawFunction implements Function {
@Override
public double evaluate(double input) {
|
return (CustomMath.mod(input/2,1)-0.5d) * 0.9d;
|
julianmaster/ChiptuneTracker
|
desktop/src/com/chiptunetracker/core/desktop/DesktopLauncher.java
|
// Path: core/src/com/chiptunetracker/core/ChiptuneTracker.java
// public class ChiptuneTracker extends Game {
// public static final String TITLE = "ChiptuneTracker";
// public static final int WINDOW_WIDTH = 29;
// public static final int WINDOW_HEIGHT = 18;
// public static final String TILESET_FILE = "wanderlust.png";
// public static final String ICON_FILE = "icon.png";
// public static final int CHARACTER_WIDTH = 12;
// public static final int CHARACTER_HEIGHT = 12;
// public static final int SCALE = 2;
//
// private static ChiptuneTracker instance = new ChiptuneTracker();
//
// private AsciiTerminal asciiTerminal;
//
// private boolean initSampleView = true;
// private boolean initPatternView = true;
//
// private Data data = new Data();
// private DataManager dataManager;
// private boolean changeData = false;
// private Chanels chanels = new Chanels();
//
// private MenuView menuView;
// private SampleView sampleView;
// private PatternView patternView;
//
// private ChiptuneTracker() {
// }
//
// @Override
// public void create () {
// asciiTerminal = new AsciiTerminal(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, TILESET_FILE, CHARACTER_WIDTH, CHARACTER_HEIGHT, SCALE);
// asciiTerminal.setDefaultCharacterBackgroundColor(Color.DARK_GRAY);
// asciiTerminal.setDefaultCharacterColor(Color.WHITE);
//
// VisUI.load();
//
// dataManager = new DataManager();
//
// menuView = new MenuView(this);
// sampleView = new SampleView(this);
// patternView = new PatternView(this);
//
// setScreen(sampleView);
// }
//
// @Override
// public void render () {
// // Sounds update
// chanels.update();
//
// // Render
// asciiTerminal.render(Gdx.graphics.getDeltaTime());
//
// // Clear
// asciiTerminal.clear();
//
// // Update
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// super.resize(width, height);
// asciiTerminal.resize(width, height);
// }
//
// @Override
// public void dispose () {
// super.dispose();
// menuView.dispose();
// sampleView.dispose();
// patternView.dispose();
// asciiTerminal.dispose();
// VisUI.dispose();
// }
//
// public static ChiptuneTracker getInstance() {
// return instance;
// }
//
// public boolean isInitSampleView() {
// return initSampleView;
// }
//
// public void setInitSampleView(boolean initSampleView) {
// this.initSampleView = initSampleView;
// }
//
// public boolean isInitPatternView() {
// return initPatternView;
// }
//
// public void setInitPatternView(boolean initPatternView) {
// this.initPatternView = initPatternView;
// }
//
// public Data getData() {
// return data;
// }
//
// public void setData(Data data) {
// this.data = data;
// }
//
// public DataManager getDataManager() {
// return dataManager;
// }
//
// public void setDataManager(DataManager dataManager) {
// this.dataManager = dataManager;
// }
//
// public boolean isChangeData() {
// return changeData;
// }
//
// public void setChangeData(boolean changeData) {
// this.changeData = changeData;
// }
//
// public AsciiTerminal getAsciiTerminal() {
// return asciiTerminal;
// }
//
// public MenuView getMenuView() {
// return menuView;
// }
//
// public SampleView getSampleView() {
// return sampleView;
// }
//
// public PatternView getPatternView() {
// return patternView;
// }
//
// public Chanels getChanels() {
// return chanels;
// }
// }
//
// Path: core/src/com/chiptunetracker/menu/ExitListener.java
// public abstract class ExitListener extends NewFileListener {
//
// public ExitListener(FileChooser fileChooser, DataManager dataManager) {
// super(fileChooser, dataManager);
// }
// }
|
import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.chiptunetracker.core.ChiptuneTracker;
import com.chiptunetracker.menu.ExitListener;
|
package com.chiptunetracker.core.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.useGL30 = true;
config.addIcon("icon_128.png", Files.FileType.Internal);
config.addIcon("icon_32.png", Files.FileType.Internal);
config.addIcon("icon_16.png", Files.FileType.Internal);
|
// Path: core/src/com/chiptunetracker/core/ChiptuneTracker.java
// public class ChiptuneTracker extends Game {
// public static final String TITLE = "ChiptuneTracker";
// public static final int WINDOW_WIDTH = 29;
// public static final int WINDOW_HEIGHT = 18;
// public static final String TILESET_FILE = "wanderlust.png";
// public static final String ICON_FILE = "icon.png";
// public static final int CHARACTER_WIDTH = 12;
// public static final int CHARACTER_HEIGHT = 12;
// public static final int SCALE = 2;
//
// private static ChiptuneTracker instance = new ChiptuneTracker();
//
// private AsciiTerminal asciiTerminal;
//
// private boolean initSampleView = true;
// private boolean initPatternView = true;
//
// private Data data = new Data();
// private DataManager dataManager;
// private boolean changeData = false;
// private Chanels chanels = new Chanels();
//
// private MenuView menuView;
// private SampleView sampleView;
// private PatternView patternView;
//
// private ChiptuneTracker() {
// }
//
// @Override
// public void create () {
// asciiTerminal = new AsciiTerminal(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, TILESET_FILE, CHARACTER_WIDTH, CHARACTER_HEIGHT, SCALE);
// asciiTerminal.setDefaultCharacterBackgroundColor(Color.DARK_GRAY);
// asciiTerminal.setDefaultCharacterColor(Color.WHITE);
//
// VisUI.load();
//
// dataManager = new DataManager();
//
// menuView = new MenuView(this);
// sampleView = new SampleView(this);
// patternView = new PatternView(this);
//
// setScreen(sampleView);
// }
//
// @Override
// public void render () {
// // Sounds update
// chanels.update();
//
// // Render
// asciiTerminal.render(Gdx.graphics.getDeltaTime());
//
// // Clear
// asciiTerminal.clear();
//
// // Update
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// super.resize(width, height);
// asciiTerminal.resize(width, height);
// }
//
// @Override
// public void dispose () {
// super.dispose();
// menuView.dispose();
// sampleView.dispose();
// patternView.dispose();
// asciiTerminal.dispose();
// VisUI.dispose();
// }
//
// public static ChiptuneTracker getInstance() {
// return instance;
// }
//
// public boolean isInitSampleView() {
// return initSampleView;
// }
//
// public void setInitSampleView(boolean initSampleView) {
// this.initSampleView = initSampleView;
// }
//
// public boolean isInitPatternView() {
// return initPatternView;
// }
//
// public void setInitPatternView(boolean initPatternView) {
// this.initPatternView = initPatternView;
// }
//
// public Data getData() {
// return data;
// }
//
// public void setData(Data data) {
// this.data = data;
// }
//
// public DataManager getDataManager() {
// return dataManager;
// }
//
// public void setDataManager(DataManager dataManager) {
// this.dataManager = dataManager;
// }
//
// public boolean isChangeData() {
// return changeData;
// }
//
// public void setChangeData(boolean changeData) {
// this.changeData = changeData;
// }
//
// public AsciiTerminal getAsciiTerminal() {
// return asciiTerminal;
// }
//
// public MenuView getMenuView() {
// return menuView;
// }
//
// public SampleView getSampleView() {
// return sampleView;
// }
//
// public PatternView getPatternView() {
// return patternView;
// }
//
// public Chanels getChanels() {
// return chanels;
// }
// }
//
// Path: core/src/com/chiptunetracker/menu/ExitListener.java
// public abstract class ExitListener extends NewFileListener {
//
// public ExitListener(FileChooser fileChooser, DataManager dataManager) {
// super(fileChooser, dataManager);
// }
// }
// Path: desktop/src/com/chiptunetracker/core/desktop/DesktopLauncher.java
import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.chiptunetracker.core.ChiptuneTracker;
import com.chiptunetracker.menu.ExitListener;
package com.chiptunetracker.core.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.useGL30 = true;
config.addIcon("icon_128.png", Files.FileType.Internal);
config.addIcon("icon_32.png", Files.FileType.Internal);
config.addIcon("icon_16.png", Files.FileType.Internal);
|
new LwjglApplication(ChiptuneTracker.getInstance(), config) {
|
julianmaster/ChiptuneTracker
|
desktop/src/com/chiptunetracker/core/desktop/DesktopLauncher.java
|
// Path: core/src/com/chiptunetracker/core/ChiptuneTracker.java
// public class ChiptuneTracker extends Game {
// public static final String TITLE = "ChiptuneTracker";
// public static final int WINDOW_WIDTH = 29;
// public static final int WINDOW_HEIGHT = 18;
// public static final String TILESET_FILE = "wanderlust.png";
// public static final String ICON_FILE = "icon.png";
// public static final int CHARACTER_WIDTH = 12;
// public static final int CHARACTER_HEIGHT = 12;
// public static final int SCALE = 2;
//
// private static ChiptuneTracker instance = new ChiptuneTracker();
//
// private AsciiTerminal asciiTerminal;
//
// private boolean initSampleView = true;
// private boolean initPatternView = true;
//
// private Data data = new Data();
// private DataManager dataManager;
// private boolean changeData = false;
// private Chanels chanels = new Chanels();
//
// private MenuView menuView;
// private SampleView sampleView;
// private PatternView patternView;
//
// private ChiptuneTracker() {
// }
//
// @Override
// public void create () {
// asciiTerminal = new AsciiTerminal(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, TILESET_FILE, CHARACTER_WIDTH, CHARACTER_HEIGHT, SCALE);
// asciiTerminal.setDefaultCharacterBackgroundColor(Color.DARK_GRAY);
// asciiTerminal.setDefaultCharacterColor(Color.WHITE);
//
// VisUI.load();
//
// dataManager = new DataManager();
//
// menuView = new MenuView(this);
// sampleView = new SampleView(this);
// patternView = new PatternView(this);
//
// setScreen(sampleView);
// }
//
// @Override
// public void render () {
// // Sounds update
// chanels.update();
//
// // Render
// asciiTerminal.render(Gdx.graphics.getDeltaTime());
//
// // Clear
// asciiTerminal.clear();
//
// // Update
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// super.resize(width, height);
// asciiTerminal.resize(width, height);
// }
//
// @Override
// public void dispose () {
// super.dispose();
// menuView.dispose();
// sampleView.dispose();
// patternView.dispose();
// asciiTerminal.dispose();
// VisUI.dispose();
// }
//
// public static ChiptuneTracker getInstance() {
// return instance;
// }
//
// public boolean isInitSampleView() {
// return initSampleView;
// }
//
// public void setInitSampleView(boolean initSampleView) {
// this.initSampleView = initSampleView;
// }
//
// public boolean isInitPatternView() {
// return initPatternView;
// }
//
// public void setInitPatternView(boolean initPatternView) {
// this.initPatternView = initPatternView;
// }
//
// public Data getData() {
// return data;
// }
//
// public void setData(Data data) {
// this.data = data;
// }
//
// public DataManager getDataManager() {
// return dataManager;
// }
//
// public void setDataManager(DataManager dataManager) {
// this.dataManager = dataManager;
// }
//
// public boolean isChangeData() {
// return changeData;
// }
//
// public void setChangeData(boolean changeData) {
// this.changeData = changeData;
// }
//
// public AsciiTerminal getAsciiTerminal() {
// return asciiTerminal;
// }
//
// public MenuView getMenuView() {
// return menuView;
// }
//
// public SampleView getSampleView() {
// return sampleView;
// }
//
// public PatternView getPatternView() {
// return patternView;
// }
//
// public Chanels getChanels() {
// return chanels;
// }
// }
//
// Path: core/src/com/chiptunetracker/menu/ExitListener.java
// public abstract class ExitListener extends NewFileListener {
//
// public ExitListener(FileChooser fileChooser, DataManager dataManager) {
// super(fileChooser, dataManager);
// }
// }
|
import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.chiptunetracker.core.ChiptuneTracker;
import com.chiptunetracker.menu.ExitListener;
|
package com.chiptunetracker.core.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.useGL30 = true;
config.addIcon("icon_128.png", Files.FileType.Internal);
config.addIcon("icon_32.png", Files.FileType.Internal);
config.addIcon("icon_16.png", Files.FileType.Internal);
new LwjglApplication(ChiptuneTracker.getInstance(), config) {
@Override
public void exit() {
|
// Path: core/src/com/chiptunetracker/core/ChiptuneTracker.java
// public class ChiptuneTracker extends Game {
// public static final String TITLE = "ChiptuneTracker";
// public static final int WINDOW_WIDTH = 29;
// public static final int WINDOW_HEIGHT = 18;
// public static final String TILESET_FILE = "wanderlust.png";
// public static final String ICON_FILE = "icon.png";
// public static final int CHARACTER_WIDTH = 12;
// public static final int CHARACTER_HEIGHT = 12;
// public static final int SCALE = 2;
//
// private static ChiptuneTracker instance = new ChiptuneTracker();
//
// private AsciiTerminal asciiTerminal;
//
// private boolean initSampleView = true;
// private boolean initPatternView = true;
//
// private Data data = new Data();
// private DataManager dataManager;
// private boolean changeData = false;
// private Chanels chanels = new Chanels();
//
// private MenuView menuView;
// private SampleView sampleView;
// private PatternView patternView;
//
// private ChiptuneTracker() {
// }
//
// @Override
// public void create () {
// asciiTerminal = new AsciiTerminal(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, TILESET_FILE, CHARACTER_WIDTH, CHARACTER_HEIGHT, SCALE);
// asciiTerminal.setDefaultCharacterBackgroundColor(Color.DARK_GRAY);
// asciiTerminal.setDefaultCharacterColor(Color.WHITE);
//
// VisUI.load();
//
// dataManager = new DataManager();
//
// menuView = new MenuView(this);
// sampleView = new SampleView(this);
// patternView = new PatternView(this);
//
// setScreen(sampleView);
// }
//
// @Override
// public void render () {
// // Sounds update
// chanels.update();
//
// // Render
// asciiTerminal.render(Gdx.graphics.getDeltaTime());
//
// // Clear
// asciiTerminal.clear();
//
// // Update
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// super.resize(width, height);
// asciiTerminal.resize(width, height);
// }
//
// @Override
// public void dispose () {
// super.dispose();
// menuView.dispose();
// sampleView.dispose();
// patternView.dispose();
// asciiTerminal.dispose();
// VisUI.dispose();
// }
//
// public static ChiptuneTracker getInstance() {
// return instance;
// }
//
// public boolean isInitSampleView() {
// return initSampleView;
// }
//
// public void setInitSampleView(boolean initSampleView) {
// this.initSampleView = initSampleView;
// }
//
// public boolean isInitPatternView() {
// return initPatternView;
// }
//
// public void setInitPatternView(boolean initPatternView) {
// this.initPatternView = initPatternView;
// }
//
// public Data getData() {
// return data;
// }
//
// public void setData(Data data) {
// this.data = data;
// }
//
// public DataManager getDataManager() {
// return dataManager;
// }
//
// public void setDataManager(DataManager dataManager) {
// this.dataManager = dataManager;
// }
//
// public boolean isChangeData() {
// return changeData;
// }
//
// public void setChangeData(boolean changeData) {
// this.changeData = changeData;
// }
//
// public AsciiTerminal getAsciiTerminal() {
// return asciiTerminal;
// }
//
// public MenuView getMenuView() {
// return menuView;
// }
//
// public SampleView getSampleView() {
// return sampleView;
// }
//
// public PatternView getPatternView() {
// return patternView;
// }
//
// public Chanels getChanels() {
// return chanels;
// }
// }
//
// Path: core/src/com/chiptunetracker/menu/ExitListener.java
// public abstract class ExitListener extends NewFileListener {
//
// public ExitListener(FileChooser fileChooser, DataManager dataManager) {
// super(fileChooser, dataManager);
// }
// }
// Path: desktop/src/com/chiptunetracker/core/desktop/DesktopLauncher.java
import com.badlogic.gdx.Files;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
import com.chiptunetracker.core.ChiptuneTracker;
import com.chiptunetracker.menu.ExitListener;
package com.chiptunetracker.core.desktop;
public class DesktopLauncher {
public static void main (String[] arg) {
LwjglApplicationConfiguration config = new LwjglApplicationConfiguration();
config.useGL30 = true;
config.addIcon("icon_128.png", Files.FileType.Internal);
config.addIcon("icon_32.png", Files.FileType.Internal);
config.addIcon("icon_16.png", Files.FileType.Internal);
new LwjglApplication(ChiptuneTracker.getInstance(), config) {
@Override
public void exit() {
|
new ExitListener(ChiptuneTracker.getInstance().getDataManager().getFileChooser(), ChiptuneTracker.getInstance().getDataManager()) {
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/UnevenTriFunction.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class UnevenTriFunction implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/UnevenTriFunction.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class UnevenTriFunction implements Function {
@Override
public double evaluate(double input) {
|
double t = CustomMath.mod(input/2d,1d);
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/DemiTriFunction.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class DemiTriFunction implements Function {
@Override
public double evaluate(double input) {
input=input*2;
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/DemiTriFunction.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class DemiTriFunction implements Function {
@Override
public double evaluate(double input) {
input=input*2;
|
return (Math.abs(CustomMath.mod(input,2)-1)-0.5 + (Math.abs(CustomMath.mod((input*0.5),2)-1)-0.5)/2-0.1) * 0.7;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/SqrFunction.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class SqrFunction implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/SqrFunction.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class SqrFunction implements Function {
@Override
public double evaluate(double input) {
|
return (CustomMath.mod(input/2d,1) < 0.5d ? 1d : -1d) * 1d/3d;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/core/Chanels.java
|
// Path: core/src/com/chiptunetracker/model/Pattern.java
// public class Pattern {
// @Attribute(required=false)
// public Integer sample1;
//
// @Attribute(required=false)
// public Integer sample2;
//
// @Attribute(required=false)
// public Integer sample3;
//
// @Attribute(required=false)
// public Integer sample4;
//
// public LinkedList<Integer> getList() {
// return new LinkedList<Integer>(){{
// add(sample1);
// add(sample2);
// add(sample3);
// add(sample4);
// }};
// }
// }
//
// Path: core/src/com/chiptunetracker/model/Sound.java
// public class Sound {
// @Attribute
// public Note note;
//
// @Attribute
// public Integer octave;
//
// @Attribute
// public Integer instrument;
//
// @Attribute
// public Integer volume;
//
// @Attribute
// public Integer effect;
//
// public Sound() {
// octave = null;
// note = null;
// instrument = null;
// volume = null;
// effect = null;
// }
//
// public Sound(Note note, Integer octave, Integer instrument, Integer volume, Integer effect) {
// this.note = note;
// this.octave = octave;
// this.instrument = instrument;
// this.volume = volume;
// this.effect = effect;
// }
// }
|
import com.chiptunetracker.model.Pattern;
import com.chiptunetracker.model.Sound;
import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.LineOut;
|
package com.chiptunetracker.core;
public class Chanels {
public final static int CHANELS = 4;
private Chanel[] chanels;
private Synthesizer synth;
private LineOut lineOut;
private boolean playSample = false;
private boolean playPattern = false;
private boolean start = false;
private int currentPattern;
public Chanels() {
synth = JSyn.createSynthesizer();
lineOut = new LineOut();
synth.add(lineOut);
chanels = new Chanel[CHANELS];
for(int i = 0; i < CHANELS; i++) {
chanels[i] = new Chanel(this);
}
synth.start();
lineOut.start();
}
/**
* ----------
* Sound
* ----------
*/
|
// Path: core/src/com/chiptunetracker/model/Pattern.java
// public class Pattern {
// @Attribute(required=false)
// public Integer sample1;
//
// @Attribute(required=false)
// public Integer sample2;
//
// @Attribute(required=false)
// public Integer sample3;
//
// @Attribute(required=false)
// public Integer sample4;
//
// public LinkedList<Integer> getList() {
// return new LinkedList<Integer>(){{
// add(sample1);
// add(sample2);
// add(sample3);
// add(sample4);
// }};
// }
// }
//
// Path: core/src/com/chiptunetracker/model/Sound.java
// public class Sound {
// @Attribute
// public Note note;
//
// @Attribute
// public Integer octave;
//
// @Attribute
// public Integer instrument;
//
// @Attribute
// public Integer volume;
//
// @Attribute
// public Integer effect;
//
// public Sound() {
// octave = null;
// note = null;
// instrument = null;
// volume = null;
// effect = null;
// }
//
// public Sound(Note note, Integer octave, Integer instrument, Integer volume, Integer effect) {
// this.note = note;
// this.octave = octave;
// this.instrument = instrument;
// this.volume = volume;
// this.effect = effect;
// }
// }
// Path: core/src/com/chiptunetracker/core/Chanels.java
import com.chiptunetracker.model.Pattern;
import com.chiptunetracker.model.Sound;
import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.LineOut;
package com.chiptunetracker.core;
public class Chanels {
public final static int CHANELS = 4;
private Chanel[] chanels;
private Synthesizer synth;
private LineOut lineOut;
private boolean playSample = false;
private boolean playPattern = false;
private boolean start = false;
private int currentPattern;
public Chanels() {
synth = JSyn.createSynthesizer();
lineOut = new LineOut();
synth.add(lineOut);
chanels = new Chanel[CHANELS];
for(int i = 0; i < CHANELS; i++) {
chanels[i] = new Chanel(this);
}
synth.start();
lineOut.start();
}
/**
* ----------
* Sound
* ----------
*/
|
public void playSound(Sound sound, int position) {
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/core/Chanels.java
|
// Path: core/src/com/chiptunetracker/model/Pattern.java
// public class Pattern {
// @Attribute(required=false)
// public Integer sample1;
//
// @Attribute(required=false)
// public Integer sample2;
//
// @Attribute(required=false)
// public Integer sample3;
//
// @Attribute(required=false)
// public Integer sample4;
//
// public LinkedList<Integer> getList() {
// return new LinkedList<Integer>(){{
// add(sample1);
// add(sample2);
// add(sample3);
// add(sample4);
// }};
// }
// }
//
// Path: core/src/com/chiptunetracker/model/Sound.java
// public class Sound {
// @Attribute
// public Note note;
//
// @Attribute
// public Integer octave;
//
// @Attribute
// public Integer instrument;
//
// @Attribute
// public Integer volume;
//
// @Attribute
// public Integer effect;
//
// public Sound() {
// octave = null;
// note = null;
// instrument = null;
// volume = null;
// effect = null;
// }
//
// public Sound(Note note, Integer octave, Integer instrument, Integer volume, Integer effect) {
// this.note = note;
// this.octave = octave;
// this.instrument = instrument;
// this.volume = volume;
// this.effect = effect;
// }
// }
|
import com.chiptunetracker.model.Pattern;
import com.chiptunetracker.model.Sound;
import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.LineOut;
|
/**
* ----------
* Next
* ----------
*/
public void next() {
if(playSample) {
chanels[0].stop();
playSample = false;
}
if(playPattern) {
if(start) {
for(int i = 0; i < CHANELS; i++) {
chanels[i].stop();
}
}
for(int i = 0; i < CHANELS; i++) {
chanels[i].clear();
}
if(currentPattern >= ChiptuneTracker.getInstance().getData().patterns.size()) {
playPattern = false;
return;
}
|
// Path: core/src/com/chiptunetracker/model/Pattern.java
// public class Pattern {
// @Attribute(required=false)
// public Integer sample1;
//
// @Attribute(required=false)
// public Integer sample2;
//
// @Attribute(required=false)
// public Integer sample3;
//
// @Attribute(required=false)
// public Integer sample4;
//
// public LinkedList<Integer> getList() {
// return new LinkedList<Integer>(){{
// add(sample1);
// add(sample2);
// add(sample3);
// add(sample4);
// }};
// }
// }
//
// Path: core/src/com/chiptunetracker/model/Sound.java
// public class Sound {
// @Attribute
// public Note note;
//
// @Attribute
// public Integer octave;
//
// @Attribute
// public Integer instrument;
//
// @Attribute
// public Integer volume;
//
// @Attribute
// public Integer effect;
//
// public Sound() {
// octave = null;
// note = null;
// instrument = null;
// volume = null;
// effect = null;
// }
//
// public Sound(Note note, Integer octave, Integer instrument, Integer volume, Integer effect) {
// this.note = note;
// this.octave = octave;
// this.instrument = instrument;
// this.volume = volume;
// this.effect = effect;
// }
// }
// Path: core/src/com/chiptunetracker/core/Chanels.java
import com.chiptunetracker.model.Pattern;
import com.chiptunetracker.model.Sound;
import com.jsyn.JSyn;
import com.jsyn.Synthesizer;
import com.jsyn.unitgen.LineOut;
/**
* ----------
* Next
* ----------
*/
public void next() {
if(playSample) {
chanels[0].stop();
playSample = false;
}
if(playPattern) {
if(start) {
for(int i = 0; i < CHANELS; i++) {
chanels[i].stop();
}
}
for(int i = 0; i < CHANELS; i++) {
chanels[i].clear();
}
if(currentPattern >= ChiptuneTracker.getInstance().getData().patterns.size()) {
playPattern = false;
return;
}
|
Pattern pattern = ChiptuneTracker.getInstance().getData().patterns.get(currentPattern);
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/DetunedTriFunction2.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class DetunedTriFunction2 implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/DetunedTriFunction2.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class DetunedTriFunction2 implements Function {
@Override
public double evaluate(double input) {
|
return ((Math.abs(CustomMath.mod((input * 127d / 128d),2d) - 1d) - 0.5d) / 2d - 0.1d) * 0.7d;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/view/View.java
|
// Path: core/src/com/chiptunetracker/core/ChiptuneTracker.java
// public class ChiptuneTracker extends Game {
// public static final String TITLE = "ChiptuneTracker";
// public static final int WINDOW_WIDTH = 29;
// public static final int WINDOW_HEIGHT = 18;
// public static final String TILESET_FILE = "wanderlust.png";
// public static final String ICON_FILE = "icon.png";
// public static final int CHARACTER_WIDTH = 12;
// public static final int CHARACTER_HEIGHT = 12;
// public static final int SCALE = 2;
//
// private static ChiptuneTracker instance = new ChiptuneTracker();
//
// private AsciiTerminal asciiTerminal;
//
// private boolean initSampleView = true;
// private boolean initPatternView = true;
//
// private Data data = new Data();
// private DataManager dataManager;
// private boolean changeData = false;
// private Chanels chanels = new Chanels();
//
// private MenuView menuView;
// private SampleView sampleView;
// private PatternView patternView;
//
// private ChiptuneTracker() {
// }
//
// @Override
// public void create () {
// asciiTerminal = new AsciiTerminal(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, TILESET_FILE, CHARACTER_WIDTH, CHARACTER_HEIGHT, SCALE);
// asciiTerminal.setDefaultCharacterBackgroundColor(Color.DARK_GRAY);
// asciiTerminal.setDefaultCharacterColor(Color.WHITE);
//
// VisUI.load();
//
// dataManager = new DataManager();
//
// menuView = new MenuView(this);
// sampleView = new SampleView(this);
// patternView = new PatternView(this);
//
// setScreen(sampleView);
// }
//
// @Override
// public void render () {
// // Sounds update
// chanels.update();
//
// // Render
// asciiTerminal.render(Gdx.graphics.getDeltaTime());
//
// // Clear
// asciiTerminal.clear();
//
// // Update
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// super.resize(width, height);
// asciiTerminal.resize(width, height);
// }
//
// @Override
// public void dispose () {
// super.dispose();
// menuView.dispose();
// sampleView.dispose();
// patternView.dispose();
// asciiTerminal.dispose();
// VisUI.dispose();
// }
//
// public static ChiptuneTracker getInstance() {
// return instance;
// }
//
// public boolean isInitSampleView() {
// return initSampleView;
// }
//
// public void setInitSampleView(boolean initSampleView) {
// this.initSampleView = initSampleView;
// }
//
// public boolean isInitPatternView() {
// return initPatternView;
// }
//
// public void setInitPatternView(boolean initPatternView) {
// this.initPatternView = initPatternView;
// }
//
// public Data getData() {
// return data;
// }
//
// public void setData(Data data) {
// this.data = data;
// }
//
// public DataManager getDataManager() {
// return dataManager;
// }
//
// public void setDataManager(DataManager dataManager) {
// this.dataManager = dataManager;
// }
//
// public boolean isChangeData() {
// return changeData;
// }
//
// public void setChangeData(boolean changeData) {
// this.changeData = changeData;
// }
//
// public AsciiTerminal getAsciiTerminal() {
// return asciiTerminal;
// }
//
// public MenuView getMenuView() {
// return menuView;
// }
//
// public SampleView getSampleView() {
// return sampleView;
// }
//
// public PatternView getPatternView() {
// return patternView;
// }
//
// public Chanels getChanels() {
// return chanels;
// }
// }
|
import com.asciiterminal.ui.AsciiSelectableTerminalButton;
import com.asciiterminal.ui.AsciiTerminal;
import com.asciiterminal.ui.AsciiTerminalButton;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.chiptunetracker.core.ChiptuneTracker;
import java.util.ArrayList;
import java.util.List;
|
package com.chiptunetracker.view;
public abstract class View extends ScreenAdapter {
public static final Color INDIGO = new Color(0x3D51B5FF);
public static final Color DEEP_ORANGE = new Color(0xFF7808FF);
public static final String DOT = String.valueOf((char)239);
|
// Path: core/src/com/chiptunetracker/core/ChiptuneTracker.java
// public class ChiptuneTracker extends Game {
// public static final String TITLE = "ChiptuneTracker";
// public static final int WINDOW_WIDTH = 29;
// public static final int WINDOW_HEIGHT = 18;
// public static final String TILESET_FILE = "wanderlust.png";
// public static final String ICON_FILE = "icon.png";
// public static final int CHARACTER_WIDTH = 12;
// public static final int CHARACTER_HEIGHT = 12;
// public static final int SCALE = 2;
//
// private static ChiptuneTracker instance = new ChiptuneTracker();
//
// private AsciiTerminal asciiTerminal;
//
// private boolean initSampleView = true;
// private boolean initPatternView = true;
//
// private Data data = new Data();
// private DataManager dataManager;
// private boolean changeData = false;
// private Chanels chanels = new Chanels();
//
// private MenuView menuView;
// private SampleView sampleView;
// private PatternView patternView;
//
// private ChiptuneTracker() {
// }
//
// @Override
// public void create () {
// asciiTerminal = new AsciiTerminal(TITLE, WINDOW_WIDTH, WINDOW_HEIGHT, TILESET_FILE, CHARACTER_WIDTH, CHARACTER_HEIGHT, SCALE);
// asciiTerminal.setDefaultCharacterBackgroundColor(Color.DARK_GRAY);
// asciiTerminal.setDefaultCharacterColor(Color.WHITE);
//
// VisUI.load();
//
// dataManager = new DataManager();
//
// menuView = new MenuView(this);
// sampleView = new SampleView(this);
// patternView = new PatternView(this);
//
// setScreen(sampleView);
// }
//
// @Override
// public void render () {
// // Sounds update
// chanels.update();
//
// // Render
// asciiTerminal.render(Gdx.graphics.getDeltaTime());
//
// // Clear
// asciiTerminal.clear();
//
// // Update
// super.render();
// }
//
// @Override
// public void resize(int width, int height) {
// super.resize(width, height);
// asciiTerminal.resize(width, height);
// }
//
// @Override
// public void dispose () {
// super.dispose();
// menuView.dispose();
// sampleView.dispose();
// patternView.dispose();
// asciiTerminal.dispose();
// VisUI.dispose();
// }
//
// public static ChiptuneTracker getInstance() {
// return instance;
// }
//
// public boolean isInitSampleView() {
// return initSampleView;
// }
//
// public void setInitSampleView(boolean initSampleView) {
// this.initSampleView = initSampleView;
// }
//
// public boolean isInitPatternView() {
// return initPatternView;
// }
//
// public void setInitPatternView(boolean initPatternView) {
// this.initPatternView = initPatternView;
// }
//
// public Data getData() {
// return data;
// }
//
// public void setData(Data data) {
// this.data = data;
// }
//
// public DataManager getDataManager() {
// return dataManager;
// }
//
// public void setDataManager(DataManager dataManager) {
// this.dataManager = dataManager;
// }
//
// public boolean isChangeData() {
// return changeData;
// }
//
// public void setChangeData(boolean changeData) {
// this.changeData = changeData;
// }
//
// public AsciiTerminal getAsciiTerminal() {
// return asciiTerminal;
// }
//
// public MenuView getMenuView() {
// return menuView;
// }
//
// public SampleView getSampleView() {
// return sampleView;
// }
//
// public PatternView getPatternView() {
// return patternView;
// }
//
// public Chanels getChanels() {
// return chanels;
// }
// }
// Path: core/src/com/chiptunetracker/view/View.java
import com.asciiterminal.ui.AsciiSelectableTerminalButton;
import com.asciiterminal.ui.AsciiTerminal;
import com.asciiterminal.ui.AsciiTerminalButton;
import com.badlogic.gdx.ScreenAdapter;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Touchable;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.chiptunetracker.core.ChiptuneTracker;
import java.util.ArrayList;
import java.util.List;
package com.chiptunetracker.view;
public abstract class View extends ScreenAdapter {
public static final Color INDIGO = new Color(0x3D51B5FF);
public static final Color DEEP_ORANGE = new Color(0xFF7808FF);
public static final String DOT = String.valueOf((char)239);
|
protected final ChiptuneTracker chiptuneTracker;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/TriFunction.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class TriFunction implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/TriFunction.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class TriFunction implements Function {
@Override
public double evaluate(double input) {
|
return (Math.abs(CustomMath.mod(input/2d,1d)*2d-1d)*2d-1d) * 0.7d;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/PulseFunction.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class PulseFunction implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/PulseFunction.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class PulseFunction implements Function {
@Override
public double evaluate(double input) {
|
return (CustomMath.mod(input/2,1) < 0.3125d ? 1d : -1d) * 1d/3d;
|
julianmaster/ChiptuneTracker
|
core/src/com/chiptunetracker/osc/DetunedTriFunction1.java
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
|
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
|
package com.chiptunetracker.osc;
public class DetunedTriFunction1 implements Function {
@Override
public double evaluate(double input) {
|
// Path: core/src/com/chiptunetracker/util/CustomMath.java
// public class CustomMath {
//
// public static double mod(double a, double b) {
// return (a % b + b) % b;
// }
// }
// Path: core/src/com/chiptunetracker/osc/DetunedTriFunction1.java
import com.chiptunetracker.util.CustomMath;
import com.jsyn.data.Function;
package com.chiptunetracker.osc;
public class DetunedTriFunction1 implements Function {
@Override
public double evaluate(double input) {
|
return (Math.abs(CustomMath.mod(input,2d)-1d) - 0.5d);
|
jlachowski/clonedigger
|
org.clonedigger/src/org/clonedigger/actions/UpdateAction.java
|
// Path: org.clonedigger/src/org/clonedigger/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "org.clonedigger";
//
// // The shared instance
// private static Activator plugin;
//
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void log(Throwable e) {
// try {
// Status s = new Status(IStatus.ERROR, PLUGIN_ID,
// e.getMessage() != null ? e.getMessage() : "No message gotten.", e);
// getDefault().getLog().log(s);
// } catch (Throwable e1) {
// //logging should never fail!
// }
// }
//
// /**
// * Returns an image descriptor for the image file at the given
// * plug-in relative path
// *
// * @param path the path
// * @return the image descriptor
// */
// public static ImageDescriptor getImageDescriptor(String path) {
// return imageDescriptorFromPlugin(PLUGIN_ID, path);
// }
// }
|
import java.io.File;
import java.io.IOException;
import org.clonedigger.Activator;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.osgi.framework.Bundle;
|
}
if (!(f.delete())) {
throw new java.io.IOException("cannot delete "+f.getPath());
}
}
/**
* The action has been activated. The argument of the
* method represents the 'real' action sitting
* in the workbench UI.
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action)
{
Bundle bundle = Platform.getBundle("org.clonedigger");
String runpath = "";
try {
runpath = FileLocator.toFileURL(bundle.getEntry("runclonedigger.py")).getPath();
if(WINDOWS) runpath = runpath.replaceAll("^/+", "");
String ppath = (new File(runpath)).getParent() + "/CloneDigger";
delrec(new File(ppath));
MessageDialog.openInformation(
null,
"CloneDigger Plug-in",
"CloneDigger will be automatically updated during the next run."
);
} catch (IOException e) {
|
// Path: org.clonedigger/src/org/clonedigger/Activator.java
// public class Activator extends AbstractUIPlugin {
//
// // The plug-in ID
// public static final String PLUGIN_ID = "org.clonedigger";
//
// // The shared instance
// private static Activator plugin;
//
// public Activator() {
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
// */
// public void start(BundleContext context) throws Exception {
// super.start(context);
// plugin = this;
// }
//
// /*
// * (non-Javadoc)
// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
// */
// public void stop(BundleContext context) throws Exception {
// plugin = null;
// super.stop(context);
// }
//
// /**
// * Returns the shared instance
// *
// * @return the shared instance
// */
// public static Activator getDefault() {
// return plugin;
// }
//
// public static void log(Throwable e) {
// try {
// Status s = new Status(IStatus.ERROR, PLUGIN_ID,
// e.getMessage() != null ? e.getMessage() : "No message gotten.", e);
// getDefault().getLog().log(s);
// } catch (Throwable e1) {
// //logging should never fail!
// }
// }
//
// /**
// * Returns an image descriptor for the image file at the given
// * plug-in relative path
// *
// * @param path the path
// * @return the image descriptor
// */
// public static ImageDescriptor getImageDescriptor(String path) {
// return imageDescriptorFromPlugin(PLUGIN_ID, path);
// }
// }
// Path: org.clonedigger/src/org/clonedigger/actions/UpdateAction.java
import java.io.File;
import java.io.IOException;
import org.clonedigger.Activator;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.osgi.framework.Bundle;
}
if (!(f.delete())) {
throw new java.io.IOException("cannot delete "+f.getPath());
}
}
/**
* The action has been activated. The argument of the
* method represents the 'real' action sitting
* in the workbench UI.
* @see IWorkbenchWindowActionDelegate#run
*/
public void run(IAction action)
{
Bundle bundle = Platform.getBundle("org.clonedigger");
String runpath = "";
try {
runpath = FileLocator.toFileURL(bundle.getEntry("runclonedigger.py")).getPath();
if(WINDOWS) runpath = runpath.replaceAll("^/+", "");
String ppath = (new File(runpath)).getParent() + "/CloneDigger";
delrec(new File(ppath));
MessageDialog.openInformation(
null,
"CloneDigger Plug-in",
"CloneDigger will be automatically updated during the next run."
);
} catch (IOException e) {
|
Activator.log(e);
|
Nilhcem/devfestnantes-2016
|
app/src/test/java/com/nilhcem/devfestnantes/data/app/SelectedSessionsMemoryTest.java
|
// Path: app/src/main/java/com/nilhcem/devfestnantes/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
|
import android.os.Build;
import com.nilhcem.devfestnantes.BuildConfig;
import com.nilhcem.devfestnantes.data.app.model.Session;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
|
package com.nilhcem.devfestnantes.data.app;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class SelectedSessionsMemoryTest {
private final SelectedSessionsMemory memory = new SelectedSessionsMemory();
@Test
public void should_set_selected_sessions() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
// When
assertThat(memory.get(now)).isNull();
memory.setSelectedSessions(map);
// Then
assertThat(memory.get(now)).isEqualTo(1);
}
@Test
public void should_remove_previous_session_when_adding_a_new_one_for_the_same_slot_time() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
memory.setSelectedSessions(map);
|
// Path: app/src/main/java/com/nilhcem/devfestnantes/data/app/model/Session.java
// @Value
// public class Session implements Parcelable {
//
// public static final Parcelable.Creator<Session> CREATOR = new Parcelable.Creator<Session>() {
// public Session createFromParcel(Parcel source) {
// return new Session(source);
// }
//
// public Session[] newArray(int size) {
// return new Session[size];
// }
// };
//
// int id;
// String room;
// List<Speaker> speakers;
// String title;
// String description;
// LocalDateTime fromTime;
// LocalDateTime toTime;
//
// public Session(int id, String room, List<Speaker> speakers, String title, String description, LocalDateTime fromTime, LocalDateTime toTime) {
// this.id = id;
// this.room = room;
// this.speakers = speakers;
// this.title = title;
// this.description = description;
// this.fromTime = fromTime;
// this.toTime = toTime;
// }
//
// protected Session(Parcel in) {
// id = in.readInt();
// room = in.readString();
// speakers = in.createTypedArrayList(Speaker.CREATOR);
// title = in.readString();
// description = in.readString();
// fromTime = (LocalDateTime) in.readSerializable();
// toTime = (LocalDateTime) in.readSerializable();
// }
//
// @Override
// public int describeContents() {
// return 0;
// }
//
// @Override
// public void writeToParcel(Parcel dest, int flags) {
// dest.writeInt(id);
// dest.writeString(room);
// dest.writeTypedList(speakers);
// dest.writeString(title);
// dest.writeString(description);
// dest.writeSerializable(fromTime);
// dest.writeSerializable(toTime);
// }
// }
// Path: app/src/test/java/com/nilhcem/devfestnantes/data/app/SelectedSessionsMemoryTest.java
import android.os.Build;
import com.nilhcem.devfestnantes.BuildConfig;
import com.nilhcem.devfestnantes.data.app.model.Session;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.threeten.bp.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import static com.google.common.truth.Truth.assertThat;
package com.nilhcem.devfestnantes.data.app;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP)
public class SelectedSessionsMemoryTest {
private final SelectedSessionsMemory memory = new SelectedSessionsMemory();
@Test
public void should_set_selected_sessions() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
// When
assertThat(memory.get(now)).isNull();
memory.setSelectedSessions(map);
// Then
assertThat(memory.get(now)).isEqualTo(1);
}
@Test
public void should_remove_previous_session_when_adding_a_new_one_for_the_same_slot_time() {
// Given
LocalDateTime now = LocalDateTime.now();
Map<LocalDateTime, Integer> map = new HashMap<>();
map.put(now, 1);
memory.setSelectedSessions(map);
|
Session toAdd = new Session(3, null, null, null, null, now, now.plusMinutes(30));
|
Nilhcem/devfestnantes-2016
|
app/src/main/java/com/nilhcem/devfestnantes/ui/settings/SettingsPresenter.java
|
// Path: app/src/main/java/com/nilhcem/devfestnantes/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
//
// @Inject SessionsReminder sessionsReminder;
//
// public BootReceiver() {
// }
//
// public static void enable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
// }
//
// public static void disable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
// }
//
// private static void setActivationState(Context context, int state) {
// ComponentName componentName = new ComponentName(context, BootReceiver.class);
// PackageManager pm = context.getPackageManager();
// pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
// }
//
// @Override
// public void onReceive(Context context, Intent intent) {
// DevFestApp.get(context).component().inject(this);
// sessionsReminder.enableSessionReminder();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devfestnantes/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session.getId()).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devfestnantes/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
//
// protected final V view;
//
// public BasePresenter(V view) {
// this.view = view;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devfestnantes/utils/App.java
// public final class App {
//
// private App() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean isCompatible(int apiLevel) {
// return android.os.Build.VERSION.SDK_INT >= apiLevel;
// }
//
// public static String getVersion() {
// String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
// if (BuildConfig.INTERNAL_BUILD) {
// version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
// }
// return version;
// }
//
// public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
// if (isCompatible(Build.VERSION_CODES.KITKAT)) {
// alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// } else {
// alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// }
// }
//
// @Nullable
// public static String getPhotoUrl(@Nullable Session session) {
// String photoUrl = null;
// if (session != null) {
// List<Speaker> speakers = session.getSpeakers();
// if (speakers != null && !speakers.isEmpty()) {
// photoUrl = speakers.get(0).getPhoto();
// }
// }
// return photoUrl;
// }
// }
|
import android.content.Context;
import com.nilhcem.devfestnantes.receiver.BootReceiver;
import com.nilhcem.devfestnantes.receiver.reminder.SessionsReminder;
import com.nilhcem.devfestnantes.ui.BasePresenter;
import com.nilhcem.devfestnantes.utils.App;
|
package com.nilhcem.devfestnantes.ui.settings;
public class SettingsPresenter extends BasePresenter<SettingsMvp.View> implements SettingsMvp.Presenter {
private final Context context;
|
// Path: app/src/main/java/com/nilhcem/devfestnantes/receiver/BootReceiver.java
// @DebugLog
// public class BootReceiver extends BroadcastReceiver {
//
// @Inject SessionsReminder sessionsReminder;
//
// public BootReceiver() {
// }
//
// public static void enable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
// }
//
// public static void disable(Context context) {
// setActivationState(context, PackageManager.COMPONENT_ENABLED_STATE_DISABLED);
// }
//
// private static void setActivationState(Context context, int state) {
// ComponentName componentName = new ComponentName(context, BootReceiver.class);
// PackageManager pm = context.getPackageManager();
// pm.setComponentEnabledSetting(componentName, state, PackageManager.DONT_KILL_APP);
// }
//
// @Override
// public void onReceive(Context context, Intent intent) {
// DevFestApp.get(context).component().inject(this);
// sessionsReminder.enableSessionReminder();
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devfestnantes/receiver/reminder/SessionsReminder.java
// @Singleton
// public class SessionsReminder {
//
// private final Context context;
// private final SessionsDao sessionsDao;
// private final SharedPreferences preferences;
// private final AlarmManager alarmManager;
//
// @Inject
// public SessionsReminder(Application app, SessionsDao sessionsDao, SharedPreferences preferences) {
// this.context = app;
// this.sessionsDao = sessionsDao;
// this.preferences = preferences;
// alarmManager = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE);
// }
//
// public boolean isEnabled() {
// return preferences.getBoolean(context.getString(R.string.settings_notify_key), false);
// }
//
// public void enableSessionReminder() {
// performOnSelectedSessions(this::addSessionReminder);
// }
//
// public void disableSessionReminder() {
// performOnSelectedSessions(this::removeSessionReminder);
// }
//
// public void addSessionReminder(@NonNull Session session) {
// if (!isEnabled()) {
// Timber.d("SessionsReminder is not enable, skip adding session");
// return;
// }
//
// PendingIntent intent = createSessionReminderIntent(session);
// LocalDateTime now = LocalDateTime.now();
// LocalDateTime sessionStartTime = session.getFromTime().minusMinutes(3);
// if (!sessionStartTime.isAfter(now)) {
// Timber.w("Do not set reminder for passed session");
// return;
// }
// Timber.d("Setting reminder on %s", sessionStartTime);
// App.setExactAlarm(alarmManager, sessionStartTime.atZone(ZoneOffset.systemDefault()).toInstant().toEpochMilli(), intent);
// }
//
// public void removeSessionReminder(@NonNull Session session) {
// Timber.d("Cancelling reminder on %s", session.getFromTime().minusMinutes(3));
// createSessionReminderIntent(session).cancel();
// }
//
// private PendingIntent createSessionReminderIntent(@NonNull Session session) {
// Intent intent = new ReminderReceiverIntentBuilder(session.getId()).build(context);
// return PendingIntent.getBroadcast(context, session.getId(), intent, PendingIntent.FLAG_UPDATE_CURRENT);
// }
//
// private void performOnSelectedSessions(Action1<? super Session> onNext) {
// sessionsDao.getSelectedSessions()
// .flatMap(Observable::from)
// .subscribeOn(Schedulers.io())
// .observeOn(Schedulers.computation())
// .subscribe(onNext, throwable -> Timber.e(throwable, "Error getting sessions"));
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devfestnantes/ui/BasePresenter.java
// public abstract class BasePresenter<V> {
//
// protected final V view;
//
// public BasePresenter(V view) {
// this.view = view;
// }
// }
//
// Path: app/src/main/java/com/nilhcem/devfestnantes/utils/App.java
// public final class App {
//
// private App() {
// throw new UnsupportedOperationException();
// }
//
// public static boolean isCompatible(int apiLevel) {
// return android.os.Build.VERSION.SDK_INT >= apiLevel;
// }
//
// public static String getVersion() {
// String version = String.format(Locale.US, "%s (#%d)", BuildConfig.VERSION_NAME, BuildConfig.VERSION_CODE);
// if (BuildConfig.INTERNAL_BUILD) {
// version = String.format(Locale.US, "%s — commit %s", version, BuildConfig.GIT_SHA);
// }
// return version;
// }
//
// public static void setExactAlarm(AlarmManager alarmManager, long triggerAtMillis, PendingIntent operation) {
// if (isCompatible(Build.VERSION_CODES.KITKAT)) {
// alarmManager.setExact(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// } else {
// alarmManager.set(AlarmManager.RTC_WAKEUP, triggerAtMillis, operation);
// }
// }
//
// @Nullable
// public static String getPhotoUrl(@Nullable Session session) {
// String photoUrl = null;
// if (session != null) {
// List<Speaker> speakers = session.getSpeakers();
// if (speakers != null && !speakers.isEmpty()) {
// photoUrl = speakers.get(0).getPhoto();
// }
// }
// return photoUrl;
// }
// }
// Path: app/src/main/java/com/nilhcem/devfestnantes/ui/settings/SettingsPresenter.java
import android.content.Context;
import com.nilhcem.devfestnantes.receiver.BootReceiver;
import com.nilhcem.devfestnantes.receiver.reminder.SessionsReminder;
import com.nilhcem.devfestnantes.ui.BasePresenter;
import com.nilhcem.devfestnantes.utils.App;
package com.nilhcem.devfestnantes.ui.settings;
public class SettingsPresenter extends BasePresenter<SettingsMvp.View> implements SettingsMvp.Presenter {
private final Context context;
|
private final SessionsReminder sessionsReminder;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.